FHIRDateFormatter
public class FHIRDateFormatter
DateFormatter
that should be used to parse FHIR date strings into dates and vice versa
-
Default initializer to create an instance of
FHIRDateFormatter
Declaration
Swift
public static let shared: FHIRDateFormatter
-
Creates a
String
representative of the passedDate
that is ideal to use for server communication since it used theISO8601DateFormatter
.Declaration
Swift
public func string(from date: Date, format: DateFormats = .yearMonthDayTime) -> String
Parameters
date
the
Date
which will be converted into a date stringformat
specify how detailed the format should be. The format can be one of the FHIR dates
Return Value
a FHIR date string in the specified format
-
Creates a
Date
from a string if it conforms to one of the FHIR date formatsYYYY, YYYY-MM, YYYY-MM-DD or YYYY-MM-DDThh:mm:ss+zz:zz
https://www.hl7.org/fhir/datatypes.htmlThe method is idle to convert a date string from a server response since it used the
ISO8601DateFormatter
.Declaration
Swift
public func date(from string: String, format: DateFormats? = nil) -> Date?
Parameters
string
a date string in one of the valid date FHIR formats or the one
format
defined explicitformat
the date
format
off the string which should be used to evaluate the string. Passnil
if the method should find the correct FHIR format.Return Value
a
Date
constructed from thestring
if the format was correct, otherwisenil
-
Creates a date string with the format
2020-06-23T09:41:00+00:00
this format is currently used by the FHIR serverDeclaration
Swift
public func stringWithLongUTCTimeZone(from date: Date) -> String
Parameters
date
the
Date
which will be converted into a date stringReturn Value
a FHIR date string with a time zone
UTC
in form+00:00
-
Declaration
Swift
public enum DateFormats : CaseIterable