f0i / iso8601 / Iso8601

Format a posix time to a ISO8601 String.

None of the generated Strings include timezone postfix.

UTC strings

toUtcString : Mode -> Time.Posix -> String

Format a String without timezone offset

toUtcDateString : Time.Posix -> String

Format a date ("YYYY-MM-DD")

toUtcTimeString : Time.Posix -> String

Format a time ("hh:mm:ss")

toUtcTimeMilliString : Time.Posix -> String

Format a time including millis ("hh:mm:ss.sss")

toUtcDateTimeString : Time.Posix -> String

Format a date time ("YYYY-MM-DDThh:mm:ss")

toUtcDateTimeMilliString : Time.Posix -> String

Format a time including millis ("YYYY-MM-DDThh:mm:ss.sss")

Custom timezone

toString : Mode -> Time.Zone -> Time.Posix -> String

Convert a posix time into a ISO8601 string

toDateString : Time.Zone -> Time.Posix -> String

Format a date ("YYYY-MM-DD")

toTimeString : Time.Zone -> Time.Posix -> String

Format a time ("hh:mm:ss")

toTimeMilliString : Time.Zone -> Time.Posix -> String

Format a time including millis ("hh:mm:ss.sss")

toDateTimeString : Time.Zone -> Time.Posix -> String

Format a date time ("YYYY-MM-DDThh:mm:ss")

toDateTimeMilliString : Time.Zone -> Time.Posix -> String

Format a time including millis ("YYYY-MM-DDThh:mm:ss.sss")

Mode for different precission


type Mode
    = Year
    | Month
    | Day
    | Hour
    | Minute
    | Second
    | Milli
    | HourOnly
    | HourMinute
    | HourSecond
    | HourMilli

The precission of the resulting String can be defined by the Mode parameter

The resulting string will have the following format

Custom format helper

toTuple : Time.Zone -> Time.Posix -> ( ( String, String, String ), ( String, String, String ), String )

Get a tuple containg strings for all date string parts

This can be used to quickly imlement your own format:

timeToString time =
    let
        ( ( year, month, day ), ( hour, minute, second ), ms ) =
            toTuple time
    in
    year ++ "/" ++ month ++ "/" ++ day ++ " " ++ hour ++ "_" ++ minute ++ "!"