This commit is contained in:
Trey t
2023-06-26 09:57:12 -05:00
parent e16a127579
commit 79ee615e8c
16 changed files with 180 additions and 39 deletions

View File

@@ -37,3 +37,22 @@ extension Date {
return isoFormatter.string(from: self)
}
}
extension String {
var dateFromServerDate: Date? {
let df = DateFormatter()
df.dateFormat = "yyyy-MM-dd'T'HH:mm:ssX"
df.locale = Locale(identifier: "en_US_POSIX")
return df.date(from: self)
}
}
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)
}
}