jweir/elm-iso8601/3.0.0

NOTE: this package is not compatible with Elm 0.19.1

ISO8601

This package provides functionality for working with time and strings based on the ISO 8601 standard i.e. 2016-03-31T12:13:14.22-04:00

Time record

type alias Time =
Model

Record representing the time. Offset is tuple representing the hour and minute ± from UTC.

type Weekday
= Mon
| Tue
| Wed
| Thu
| Fri
| Sat
| Sun

Represents one of the seven days of the week

type alias Offset =
( Int, Int )

Offset represents the hour and minute timezone offset from UTC.

Accessors

year : Time -> Int

return the year

month : Time -> Int

return the month

day : Time -> Int

return the day

hour : Time -> Int

return the hour

minute : Time -> Int

return the minute

second : Time -> Int

return the secon

millisecond : Time -> Int

return the millisecond

offset : Time -> Offset

return the offset

weekday : Time -> Weekday

Returns the day of the week from the Time record

Parsing

fromString : String -> Result String Time

Given an ISO 8601 compatible string, returns a Time record.

ISO8601.fromString "2016-01-01T01:30:00-04:00"
-- { year = 2016, month = 1, day = 1, hour = 1, minute = 30, second = 0, millisecond = 0, offset = (-4,0) }
    : ISO8601.Time
ISO8601.fromString "2016-11-07"
--{ year = 2016, month = 11, day = 7, hour = 0, minute = 0, second = 0, millisecond = 0, offset = (0,0) }
    : ISO8601.Time
```
toString : Time -> String

Converts a Time record to an ISO 8601 formated string.

Time conversion

toTime : Time -> Int

Converts the Time to milliseconds relative to the Unix epoch: 1970-01-01T00:00:00Z

fromTime : Int -> Time

Converts the milliseconds relative to the Unix epoch to a Time record.