isaacseymour/deprecated-time/1.0.0

Time.ZonedDateTime

This module defines a time representation based on a Date, the time of day and a time zone.

ZonedDateTimes should only be used when reasoning about or displaying DateTimes in a user's local time zone. For this reason, the API surface of ZonedDateTimes is extremely limited.

ZonedDateTimes

ZoneDateTime is the opaque type for all ZonedDateTime values. Values of this type represent a (TimeZone, DateTime) pair.

Constructing ZonedDateTimes

zero : DateTimeData

zero represents the first millisecond of the first day of the current era. Use it to build ZonedDateTime values:

-- 0-01-01T00:00:00+02:00
zonedDateTime (europe_bucharest ()) zero




-- 2016-01-01T00:00:00+02:00
zonedDateTime (europe_bucharest ()) { zero | year = 2016 }




-- 2016-05-29T13:00:00+02:00
zonedDateTime (europe_bucharest ()) { zero | year = 2016, month = 5, day = 29, hour = 13 }
zonedDateTime : TimeZone -> DateTimeData -> ZonedDateTime

zonedDateTime constructs a ZonedDateTime value given a TimeZone, a date and a time. Invalid values are clamped to the nearest valid date and time.

fromDateTime constructs a ZonedDateTime value from a TimeZone and a DateTime.

toDateTime converts a ZonedDateTime to a UTC DateTime value.

fromPosix converts the elm/time POSIX representation of a UNIX timestamp into a ZonedDateTime value. This is equivalent to calling DateTime.fromPosix and then converting the resulting DateTime value to a ZonedDateTime.

toPosix converts a ZonedDateTime to its UNIX timestamp representation, as an elm/time Posix time.

Inspecting ZonedDateTimes

timeZone returns a ZonedDatetime's TimeZone.

year returns a ZonedDateTime's year.

month returns a ZonedDateTime's month.

day returns a ZonedDateTime's day.

weekday returns a ZonedDateTime's day of the week.

hour returns a ZonedDateTime's hour.

minute returns a ZonedDateTime's minute.

second returns a ZonedDateTime's second.

millisecond returns a ZonedDateTime's millisecond.

abbreviation returns a ZonedDateTime's abbreviation at that time.

utcOffset returns a ZonedDateTime's offset from UTC in milliseconds at that time.

utcOffsetString returns a ZonedDateTime's UTC offset at that time as a string.

Manipulating ZonedDateTimes

asTimeZone converts a ZonedDateTime to another TimeZone.

setDate sets a ZonedDateTime's date.

setYear sets a ZonedDateTime's year.

setMonth sets a ZonedDateTime's month.

setDay sets a ZonedDateTime's day.

setHour sets a ZonedDateTime's hour.

setMinute sets a ZonedDateTime's minute.

setSecond sets a ZonedDateTime's second.

setMillisecond sets a ZonedDateTime's millisecond.

addYears adds a relative number of years to a ZonedDateTime value.

addMonths adds a relative number of months to a ZonedDateTime value.

addDays adds an absolute number of days to a ZonedDateTime value.

addHours adds a relative number of hours to a ZonedDateTime value.

addMinutes adds a relative number of minutes to a ZonedDateTime value.

addSeconds adds a relative number of seconds to a ZonedDateTime value.

addMilliseconds adds an absolute number of milliseconds to a ZonedDateTime value.