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 passed Date that is ideal to use for server communication since it used the ISO8601DateFormatter.

    Declaration

    Swift

    public func string(from date: Date, format: DateFormats = .yearMonthDayTime) -> String

    Parameters

    date

    the Date which will be converted into a date string

    format

    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 formats YYYY, YYYY-MM, YYYY-MM-DD or YYYY-MM-DDThh:mm:ss+zz:zz https://www.hl7.org/fhir/datatypes.html

    The 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 explicit

    format

    the date format off the string which should be used to evaluate the string. Pass nil if the method should find the correct FHIR format.

    Return Value

    a Date constructed from the string if the format was correct, otherwise nil

  • Creates a date string with the format 2020-06-23T09:41:00+00:00 this format is currently used by the FHIR server

    Declaration

    Swift

    public func stringWithLongUTCTimeZone(from date: Date) -> String

    Parameters

    date

    the Date which will be converted into a date string

    Return Value

    a FHIR date string with a time zone UTC in form +00:00

  • Declaration

    Swift

    public enum DateFormats : CaseIterable