Try Install Learn Blog API Packages GitHub
Pages

Time

Utility functions for working with Time.

THIS MODULE IS STILL WORK IN PROGRESS

Functions

day
(
date
:
Time
)
:
Number

Returns the UTC day of the given time.

(Time.from(2018, 4, 5)
|> Time.day()) == 5
endOf
(
what
:
String
date
:
Time
)
:
Time

Returns the end of the day / month / week of the given time.

format
(
pattern
:
String
date
:
Time
)
:
String

Formats the time using the given pattern.

from
(
year
:
Number
month
:
Number
day
:
Number
)
:
Time

Retruns a new UTC date from the given parameters.

Time.from(2018, 4, 5)
fromIso
(
raw
:
String
)
:
Maybe(Time)

Tries to parse the given string as an ISO date.

Time.fromIso("2018-04-05T00:00:00.000Z")
month
(
date
:
Time
)
:
Number

Returns the UTC month of the given time.

(Time.from(2018, 4, 5)
|> Time.month()) == 4
nextMonth
(
date
:
Time
)
:
Time

Returns the next month from the given time.

now
:
Time

Returns the current time.

previousMonth
(
date
:
Time
)
:
Time

Returns the previous month from the given time.

range
(
from
:
Time
to
:
Time
)
:
Array(Time)

Returns an array of days from the given start to given end time.

relative
(
other
:
Time
now
:
Time
)
:
String

Returns the relative time from the given times (in english).

startOf
(
what
:
String
date
:
Time
)
:
Time

Returns the start of the day / month / week of the given time.

toIso
(
date
:
Time
)
:
String

Formats the given time to the ISO format.

Time.toIso(Tome.today()) == "2018-04-05T00:00:00.000Z"
today
:
Time

Returns the time of the begging of today.

year
(
date
:
Time
)
:
Number

Returns the UTC year of the given time.

(Time.from(2018, 4, 5)
|> Time.year()) == 2018