f0i/iso8601/1.1.0

NOTE: the latest version is 1.1.2

Iso8601

Format a posix time to a ISO8601 String.

None of the generated Strings include timezone postfix.

UTC strings

toUtcString : Mode -> Posix -> String

Format a String without timezone offset

toUtcDateString : Posix -> String

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

toUtcTimeString : Posix -> String

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

toUtcTimeMilliString : Posix -> String

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

toUtcDateTimeString : Posix -> String

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

toUtcDateTimeMilliString : Posix -> String

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

Custom timezone

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

Convert a posix time into a ISO8601 string

toDateString : Zone -> Posix -> String

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

toTimeString : Zone -> Posix -> String

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

toTimeMilliString : Zone -> Posix -> String

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

toDateTimeString : Zone -> Posix -> String

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

toDateTimeMilliString : Zone -> 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

  • Year: "YYYY"
  • Month: "YYYY-MM"
  • Day: "YYYY-MM-DD"
  • Hour: "YYYY-MM-DDThh"
  • Minute: "YYYY-MM-DDThh:mm"
  • Second: "YYYY-MM-DDThh:mm:ss"
  • Milli: "YYYY-MM-DDThh:mm:ss.sss"
  • HourOnly: "hh"
  • HourMinute: "hh:mm"
  • HourSecond: "hh:mm:ss"
  • HourMilli: "hh:mm:ss.sss"

Custom format helper

Zone
-> 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 ++ "!"