rluiten/elm-date-extra/4.0.0

NOTE: this package is not compatible with Elm 0.19.1

Date.Extra.Utils

Date Utils.

Date parsing

fromString : String -> Result String Date

Elm Date.fromString suffers from the some of the same javascript unusual compensation of input ranges when converting strings to Dates.

This method makes some known undesirable no Err results return Err.

Example produces Ok "2012-03-02" in javascript

  aDate = (Date.fromString "2012-02-31")

checkDateResult tries to catch and mark as Err some of these cases.

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

Create a date in current time zone from given fields. 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.

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.

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.

Be careful with unsafeFromString it will Debug.crash() if it cant parse date.

unsafeFromString : String -> Date

Utility for known input string date creation cases. Checks for a fail just in case and calls Debug.crash().

Utility

dayList : Int -> Date -> List Date

Return a list of days dayLength long for successive days starting from startDate.

isoWeek : Date -> ( Int, Int, Int )

Return iso week values year, week, isoDayOfWeek.

isoWeekOne : Int -> Date

Return date of start of week one for year.

Copyright (c) 2016 Robin Luiten