DateConverter

public class DateConverter

Converts dates to and from API-friendly strings

  • Initializes the formatter with date format information from a budget

    Declaration

    Swift

    public init(dateFormat: DateFormat)

    Parameters

    dateFormat

    Date format information obtained from a budget

  • Converts a date sent by the API into a displayable date according to the budget format

    Declaration

    Swift

    public func budgetFormatDateString(from apiDateString: String) -> String?

    Parameters

    from

    A date string in the style (iso8601) sent by API responses (e.g. 2015/12/25)

    Return Value

    A displayable date string if conversion is successful, nil if conversion fails.

  • Converts a date sent by the API into a Date object

    Declaration

    Swift

    public static func date(from apiDateString: String) -> Date?

    Parameters

    from

    A date string in the style (iso8601) sent by API responses (e.g. 2015/12/25)

    Return Value

    A Date object, or nil if conversion fails.

  • Converts a date into a API-friendly iso8601 date string

    Declaration

    Swift

    public static func iso8601DateString(from date: Date) -> String

    Parameters

    date

    Date to be converted

    Return Value

    API-friendly iso8601 date string