rluiten/elm-date-extra/9.3.1

NOTE: this package is not compatible with Elm 0.19.1

Date.Extra.Create

Create dates and offsets.

getTimezoneOffset : Date -> Int

Return the time zone offset of current javascript environment underneath Elm in Minutes. This should produce the same result getTimezoneOffset() for a given date in the same javascript VM.

Time zone offset is always for a given date and time so an input date is required.

Given that timezones change (though slowly) this is not strictly pure, but I suspect it is sufficiently pure to be useful. Is is dependent on the timezone mechanics of the javascript VM.

Example zone stuff.

For an offset of -600 minutes, in +10:00 time zone offset.

dateFromFields : Int -> Month -> Int -> Int -> Int -> Int -> Int -> Date

Create a date in current time zone from given fields.

Call Signature

dateFromFields year month day hour minute second millisecond =

All field values are clamped to there allowed range values. Hours are input in 24 hour time range 0 to 23 valid. Returns dates in current time zone.

Using algorithm from http://howardhinnant.github.io/date_algorithms.html Specifically days_from_civil function.

The two <*>Compensate values adjust for the zone offset time

introduced by epochDate as starting point.

timeFromFields : Int -> Int -> Int -> Int -> Date

Create a time in current time zone from given fields, for when you dont care about the date part but need time part anyway.

Call Signature

timeFromFields hour minute second millisecond =

All field values are clamped to there allowed range values. This can only return dates in current time zone.

Hours are input in 24 hour time range 0 to 23 valid.

This defaults to year 1970, month Jan, day of month 1 for date part.

Copyright (c) 2016-2018 Robin Luiten