AdrianRibao/elm-derberos-date/1.2.1

NOTE: the latest version is 1.2.3

Derberos.Date.Utils

Utils for working with dates.

Functions

isLeapYear : Int -> Bool

If the year is a leap year, return True. False otherwise.

isLeapYear 2018 == False
isLeapYear 2016 == True
getNextMonth : Month -> Month

Given a month, return the next month.

getNextMonth Apr == May
getPrevMonth : Month -> Month

Given a month, return the previous month.

getPrevMonth Apr == May
monthToNumber : Month -> Int

Convert the month to a number in the range [0, 11]

monthToNumber1 : Month -> Int

Convert the month to a number in the range [1, 12]

numberToMonth : Int -> Maybe Month

Given a number from 0 to 11, convert it to the corresponding month.

numberOfDaysInMonth : Int -> Month -> Int

Return the number of days in a month.

numberOfDaysInMonth 2018 Feb == 28
numberOfDaysInMonth 2016 Feb == 29
getWeekday : Zone -> Posix -> Weekday

Given a Time, return the Weekday

getNextWeekday : Weekday -> Weekday

Given a Weekday, get the next weekday. getNextWeekday Sun == Mon

getPrevWeekday : Weekday -> Weekday

Given a Weekday, get the previous weekday. getPrevWeekday Sun == Sat

weekdayToNumber : Weekday -> Int

Convert the Weekday to a number representation. Starts with 0 on Monday.

weekdayToNumber Mon == 0
weekdayToNumber Sun == 6
weekdayFromNumber : Int -> Maybe Weekday

Convert a number to a weekday. 0 is for Monday.

weekdayFromNumber 0 == Just Mon
weekdayFromNumber 6 == Just Sun
weekdayFromNumber 8 == Nothing
weekdayDiff : Weekday -> Weekday -> Int

Get the difference in days between two weekdays. Assume always forward direction. For example, the returned value from Friday to Wednesday is 5.

weekdayDiff Fri Wed == 5
weekdayDiff Mon Wed == 2
weekdayDiffBack : Weekday -> Weekday -> Int

Get the difference in days between two weekdays. It works in the backwards direction. For example, the returned value from Friday to Wednesday is 2.

weekdayDiffBack Fri Wed == 2
weekdayDiffBack Mon Wed == 5
resetTime : Posix -> Posix

Given a datetime, set the time to 00:00:00.000

Formatting

getIsoFormat : String -> Zone -> Posix -> String

Get the iso format of the date