'.day Component returns "incorrect" day in Swift
My date object returns "incorrect" day from some reason, I have no idea why. This output is taken from the debugger:
(lldb) po date
▿ Optional<Date>
▿ some : 2022-05-13 21:06:55 +0000
- timeIntervalSinceReferenceDate : 674168815.716091
(lldb) po date.get(.day)
14
The get function:
extension Date {
func get(_ components: Calendar.Component..., calendar: Calendar = Calendar.current) -> DateComponents {
return calendar.dateComponents(Set(components), from: self)
}
func get(_ component: Calendar.Component, calendar: Calendar = Calendar.current) -> Int {
return calendar.component(component, from: self)
}
}
Any ideas what am I missing?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|