AdrianRibao/elm-derberos-date/1.1.0

NOTE: the latest version is 1.2.3

Derberos.Date.Core

Core functions for working with dates

type alias DateRecord =
{ year : Int
, month : Int
, day : Int
, hour : Int
, minute : Int
, second : Int
, millis : Int
, zone : Zone
}

Store the date in a record.

newDateRecord : Int -> Int -> Int -> Int -> Int -> Int -> Int -> Zone -> DateRecord

Generate a new DateRecord

newDateRecord 2018 2 13 19 45 0 0 == {
    year = 2018
    , month = 2
    , day = 13
    , hour = 19
    , minute = 45
    , second = 0
    , millis = 0
    }
civilToPosix : DateRecord -> Posix

Given a datetime, get the posix time.

posixToCivil : Posix -> DateRecord

Given a Posix time, get the human datetime.

type alias Config =
{ getMonthName : Month -> String
, getWeekName : Weekday -> String
, getCommonFormatDate : String -> Zone -> Posix -> String
, getCommonFormatTime : Zone -> Posix -> String
, getCommonFormatDateTime : String -> Zone -> Posix -> String
}

Store the configuration for getting i18n and l10n formats.

Timezones

getTzOffset : Zone -> Posix -> Int

Gets the difference in minutes given the current Time Zone and the utc time.

adjustMilliseconds : Zone -> Posix -> Posix

Adjust the milliseconds of the posix time.

The time has the milliseconds as if it was using UTC but it actually has a tz to be applied. So if we had 2018/10/28T01:30:00 UTC we want to convert it to 2018/10/28T01:30:00 zone so we have to substract the offset.

addTimezoneMilliseconds : Zone -> Posix -> Posix

Given a Zone and a Posix time, add the timezone offset to get the corrected date.