Skip to content

Latest commit

 

History

History
15 lines (13 loc) · 431 Bytes

DateAndTime.md

File metadata and controls

15 lines (13 loc) · 431 Bytes

Date & Time

FHIRModels handles date/time ↔︎ string conversion transparently and will discard invalid dates.

do {
    let dateTimeString = "2020-03-12T12:33:54.6543-06:00"
    let dateTime = try DateTime(dateTimeString)
    dateTime.date.year == 2020
    dateTime.time.minute == 33
    dateTime.timeZone == TimeZone(secondsFromGMT: -6 * 3600)
} catch {
    print("Failed to parse date time string: \(error)")
}