adius / vectual / TimeUtils.TimeUnit

Reduce or Increase a date to a given start or end of a TimeUnit granularity.

This allows you to modify a date to reset to minimum or maximum values all values below a given TimeUnit granularity.

This operates in local time zone so if you are not in UTC time zone and you output date in UTC time zone the date fields will not be to the start or end of the TimeUnit.

Example TimeUnit.startOfTime Hour date will return a modified date with

Example TimeUnit.endOfTime Hour date will return a modified date with

startOfTime : TimeUnit -> Time.Posix -> Time.Posix

Return a date created by reducing to minimum value all values below a given TimeUnit granularity.

This modifies date in local time zone values, as the date element parts are pulled straight from the local time zone date values.

endOfTime : TimeUnit -> Time.Posix -> Time.Posix

Return a date created by increasing to maximum value all values below a given TimeUnit granularity.

This modifies in local time zone values, as the date element parts are pulled straight from the local time zone date values.


type TimeUnit
    = Millisecond
    | Second
    | Minute
    | Hour
    | Day
    | Month
    | Year

Date granularity of operations.

timeUnitToString : TimeUnit -> String