func isDayEnded(recent: Date, previous: Date) -> Bool { let day:Int = Calendar.current.dateComponents([.day], from: previous, to: recent).day ?? 0 if day >= 1 { return true } else { return false } } let previous = NSDate(timeIntervalSince1970: 1645601459) let recent = NSDate(timeIntervalSince1970: 1648020659) let dayEnded = isDayEnded(recent: recent as Date, previous: previous as Date) print("Day = \(dayEnded)")
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter