A Date represents a moment in time, encoded by two essential pieces of
information: the number of milliseconds since 1 January 1970 UTC, and the
offset between UTC and the current machine's local time. Extractions of a
Date (e.g. Date.month, Date.hour) return representations of the date in
local time, while Date.toTime returns the UTC representation.
Convenience function for creating a Date from only the year, month, and
day parts.
Date.fromCalendarDate 2000 Jan 1Attempt to create a Date from a string representing a date in ISO 8601 format.
Date.fromIsoString "2000-01-01"
-- Just <1 January 2000, local time>
Date.fromIsoString "2009-W01-1T00Z"
-- Just <29 December 2008, UTC>
Date.fromIsoString "2016-218T20:00-03:00"
-- Just <5 August 2016, 23:00, UTC>
Date.fromIsoString "1/1/2001"
-- NothingWhen a Date is created with a specified time zone offset (e.g. "-03:00"),
its extractions still reflect the current machine's local time, and
Date.toTime still reflects its UTC time.
In some cases you may want to specify a date with a time zone offset or from
week-date or ordinal-date parts. The fromSpec function provides a way to
do this.
Create a Date from a specified time zone, time of day, and day.
Date.fromSpec
local
noTime
(calendarDate 2000 Jan 1)
-- <1 January 2000, local time>
Date.fromSpec
utc
noTime
(weekDate 2009 1 1)
-- <29 December 2008, UTC>
Date.fromSpec
(offset -180)
(atTime 20 0 0 0)
(ordinalDate 2016 218)
-- <5 August 2016, 23:00, UTC>When a Date is created with a specified time zone offset (e.g. offset -180),
its extractions still reflect the current machine's local time, and
Date.toTime still reflects its UTC time.
Represents a time zone.
UTC time zone.
Create a TimeZone with a specific offset from UTC time, given in minutes.
Do not specify a time zone, but use the local offset instead.
Represents a time of day.
Do not specify a time of day (default to 00:00).
Create a TimeSpec from time parts (hour, minute, second, millisecond).
Represents a day.
Create a DateSpec from calendar-date parts (year, month, day).
Create a DateSpec from week-date parts (weekYear, weekNumber, weekdayNumber).
Create a DateSpec from ordinal-date parts (year, ordinalDay).
Create a Date from a Julian Date.
Julian Dates always represent UTC time.
Date.fromJulianDate 2456293.52083333
-- <1 January 2013, 00:30, UTC>
Create a
Datefrom the following parts, given in local time:The values of the parts are not checked to ensure a valid date representation, nor are they clamped to valid range; instead, providing values outside a valid range results in underflow or overflow.