Pyret
This document contains the date-time library for Pyret, along with many examples and some longer descriptions of language design choices.
The official Pyret documentation can be found here.
1 Builtins and Libraries
This section contains information on libraries that come with Pyret.
1.1 duration
1.1.1 The Duration Datatype
- | duration(year :: Number, month :: Number, day :: Number, hour :: Number, minute :: Number, second :: Number)
The Duration type has several fields, combinations of which allow different ways of representing the amounts of time this library provides.
The functions associated with this type include several constructors that ensure users need not directly access this data type to construct simpler versions of durations (i.e. only years, days, or hour-minute-second triples, etc.).
In conversions and normalization, Duration assumes that a "month" duration is equivalent to 30 days and a "year" duration is equivalent to 365 days. This is done for uniformity, and differences in actual month/year lengths are more accurately reflected in the Temporal types.
There are no variants for Duration, and programs cannot use cases statements with Durations. Instead, they can be created and manipulated with the methods and functions below.
1.1.2 Duration Methods
Gets the value of the requested Duration from ’units’ with 0 for the non-requested units (i.e. without normalizing the Duration from ’units’).
check: duration(1, 11, 6, -4, 2, -4.5).get([set: unit-month]) is duration(0, 11, 0, 0, 0, 0) duration(41.3, 0, 11, 0, 23, 0).get([set: unit-day, unit-year, unit-hour]) is duration(41.3, 0, 0, 0, 0, 0) end
Returns a set of non-0 units uniquely defining the value of this Duration.
check: duration(1, 1, 1, 1, 1, 1).get-units() is [set: unit-year, unit-month, unit-day, unit-hour, unit-minute, unit-second] duration(0, 0, 2, -1.1, -5, 0).get-units() is [set: unit-day, unit-hour, unit-minute] duration(0, 0, 0, 0, 0, 0).get-units() is empty-set end
Normalize the duration into seconds and perform greedy division into a new duration for the ’units’ provided.
A normalized Duration is greedily divided such that its year attribute, followed by month attribute, and so on are as large as possible, implying that only the units in the set passed may be non-integer, and only the value of the smallest unit in the duration may be non-integer
check: duration(1, 2, 3, 4, 5, 6).normalize([set: unit-year]) is duration(1, 2, 3, 4, 5, 6) duration(1, 12, 30, 24, 60, 60).normalize([set: unit-year, unit-month, unit-day, unit-hour, unit-minute, unit-second]) is duration(2, 0, 26, 1, 1, 0) duration(-1, 2, -3, 4, -5, 6).normalize([set: unit-year, unit-hour, unit-minute, unit-second]) is ... duration(10, 20, 30, 40, 50, 60).normalize([set: unit-year, unit-month, unit-year]) is duration(11, 8, 12817/480, 0, 0, 0) end
Returns a copy of this Duration with all attributes made positive.
check: duration(1, -2, 3, -4, 5, -6).abs() is duration(1, 2, 3, 4, 5, 6) end
Returns a copy of the Duration scaled by the function ’f’.
check: duration(0, 1, -1, 11/2, -22/7, 0).scale-f(num-round) is duration(0, 1, -1, 6, -3, 0) end
Returns a copy of this Duration scaled by the passed scalar.
check: duration(2, 4, 6, 8, 10, 12).scale(0.5) is duration(1, 2, 3, 4, 5, 6) duration(2, 4, 6, 8, 10, 12).scale(0) is duration(0, 0, 0, 0, 0, 0) end
Checks if the normalized forms of this Duration and the specified Duration are equal.
check: duration(1, 20, 39, 2, -1, -90).equals(duration(1, 20, 39, 2, -1, -90)) is true duration(1, 20, 39, 2, -1, -90).equals(duration(2, 9, 4, 1, 57, 30)) is true duration(-1, -2, -3, -4, -5, -6).equals(duration(1, 2, 3, 4, 5, 6)) is false end
Checks if this Duration is negative in its normalized form.
check: duration(1, 2, 3, 4.09, 5, 6).is-negative() is false duration(-1, 2, -3, 4.09, -5, 6).is-negative() is true duration(-1, 20, -3, 4.09, -5, 6).is-negative() is false duration(0, 0, 0, 0, 0, 0).is-negative() is false end
Checks if this Duration is 0 in its normalized form.
check: duration(0, 0, 1, -24, 1, -60).is-zero() is true duration(0, 0, 0, 0, 0, 0).is-zero() is true duration(1, 2, 3, 4.09, 5, 6).is-zero() is false end
Returns a copy of this Duration with the specified unit modified to ’n’.
check: duration(-1, -2, -3, -4, -5, -6).change-unit(unit-day, 3) end) is duration(-1, -2, 3, -4, -5, -6) end
Returns a copy of this Duration with the specified Duration added.
check: duration(1, 2, 3, 4, 5, 6).plus(duration(0, 1, -3, 5, 6, -99)) is duration(1, 3, 0, 9, 11, -93) end
Returns a copy of this Duration with the specified Duration subtracted.
check: duration(1, 2, 3, 4, 5, 6).minus(duration(0, 1, 3, 5, 6, 99)) is duration(1, 1, 0, -1, -1, -93) end
Returns a copy of this Duration with the specified Duration multiplied.
check: duration(1, 2, 3, 4, 5, 6).times(duration(0, 1, 3, 5, 6, 99)) is ... end
Returns a copy of this Duration with the specified Duration divided.
check: duration(1, 2, 3, 4, 5, 6).divide(duration(0, 1, 3, 5, 6, 99)) is ... duration(1, 2, 3, 4, 5, 6).divide(duration(0, 0, 0, 0, 0, 0)) raises "division by zero" end
A string representation of this Duration using ISO-8601 seconds based representation in normalized form, such as "PT8H6M12.345S".
check: duration(1, 2, 3, 4, 5, 6).to-string() is "P1Y2M3DT4H5M6S" duration(1, 0, 0, 8, 6, 12.345).to-string() is "P1YT8H6M12.345S" end
1.1.3 Duration Functions
These functions require the Duration module to be imported, as indicated in the examples.
The input is not normalized, and is instead stored as is to account for computational use cases.
- ymd-to-duration :: (
- years :: Number,
- months :: Number,
- days :: Number
- )
- -> Duration
Obtains a duration representing an amount from the values of the years, months, and days.
check: ymd-to-duration(-4, -10, -21) is duration(-4, -10, -21, 0, 0, 0) end
- hms-to-duration :: (
- hours :: Number,
- minutes :: Number,
- seconds :: Number
- )
- -> Duration
Obtains a duration representing an amount from the values of the hours, minutes, and seconds.
check: hms-to-duration(-5, -3, -11) is duration(0, 0, 0, -5, -3, -11) end
Obtains a Duration representing a number of years.
check: years-to-duration(1) is duration(1, 0, 0, 0, 0, 0) end
Obtains a Duration representing a number of months.
check: months-to-duration(1) is duration(0, 1, 0, 0, 0, 0) end
Obtains a Duration representing a number of days.
check: days-to-duration(1) is duration(0, 0, 1, 0, 0, 0) end
Obtains a Duration representing a number of hours.
check: hours-to-duration(1) is duration(0, 0, 0, 1, 0, 0) end
Obtains a Duration representing a number of minutes.
check: minutes-to-duration(1) is duration(0, 0, 0, 0, 1, 0) end
Obtains a Duration representing a number of seconds.
check: seconds-to-duration(1) is duration(0, 0, 0, 0, 0, 1) end
1.2 day-of-week
1.2.1 The DayOfWeek Datatype
The DayOfWeek represents the possible days of the standard business week.
The e-nums 1 through 7 happen to coincide with the trade convention for weeks in the Gragorian Calendar, where 1 represents Monday, 2 represents Tuesday, and so on.
These seven variables for DayOfWeek may be created and manipulated with the methods and functions below.
1.2.2 DayOfWeek Methods
Gets the textual representation following the trade representation of the week such as ’Monday’ or ’Friday’.
check: d5.get-display-name() is "Friday" end
Gets the day-of-week Number value following the trade week representation.
check: d3.get-value() is 3 end
Returns the DayOfWeek after modifying the given DayOfWeek through ’f’.
check: d6.change(lam(x): x * -3 end) is d3 end
Returns the DayOfWeek that is the specified number of days before this one.
check: d1.subtract(10) is d5 end
Returns the number of days between the two given Days.
check: d1.between(d3) is 2 d3.between(d1) is 2 end
Returns the DayOfWeek that is the specified number of days after this one.
check: d1.add(10) is d4 end
1.2.3 DayOfWeek Functions
Obtains an instance of DayOfWeek from a Number value.
check: num-to-day(3) is d3 num-to-day(-12) is d2 num-to-day(22/7) raises "Can only create DayOfWeek from Natural Numbers" end
Returns the DayOfWeek from the specified name in trade week respresentation.
check: string-to-day("THUrsDaY") is d4 string-to-day("mon") raises "Please enter the day in full trade form eg 'Monday'" end
1.3 month-of-year
1.3.1 The MonthOfYear Datatype
The MonthOfYear represents the possible months of the standard Gregorian calendar.
The e-nums 1 through 12 happen to coincide with the conventional order of months in the Gregorian Calendar, where 1 represents January, 2 represents February, and so on.
These twelve variables for MonthOfYear may be created and manipulated with the methods and functions below.
1.3.2 MonthOfYear Methods
Gets the textual representation in the Gregorian Calendar, such as ’January’ or ’December’.
check: m8.get-display-name() is "August" end
Gets the MonthOfYear Number value following the Gregorian Calendar Convention
check: m2.get-num() is 2 end
Gets the length of this month in days.
check: m5.length(true) is 31 m5.length(false) is 31 m2.length(true) is 29 m2.length(false) is 28 end
Returns the MonthOfYear after modifying the given MonthOfYear through ’f’.
check: m7.arithmetic-f(lam(x): x * -5 end) is m1 end
Returns the MonthOfYear that is the specified number of months before this one.
check: m1.minus(20) is m5 end
Returns the number of months between the specified months
check: m1.between(m5) is 4 m5.between(m1) is 4 end
Returns the MonthOfYear that is the specified number of months after this one.
check: m1.plus(20) is m9 end
1.3.3 MonthOfYear Functions
These functions require the MonthOfYear module to be imported, as indicated in the examples.
Obtains an instance of MonthOfYear from a Number value.
check: num-to-month(3) is m3 num-to-month(-39) is m9 num-to-month(22/7) raises "Can only create MonthOfYear from Natural Numbers" end
Returns the MonthOfYear from the specified name in trade week respresentation.
check: string-to-month("junE") is m6 string-to-month("JAN") raises "Please enter the month in full Gregorian form eg January" end
1.4 zone-offset
1.4.1 The ZoneOffset Datatype
The ZoneOffset stores the interval between two durations in the form of a time-zone offset.
In effect, a ZoneOffset of (0, 0) represents UTC or GMT, (-5, 0) represents EST, ()and so on.
1.4.2 ZoneOffset Methods
Finds the difference between two ZoneOffsets as a Duration.
check: zone-offset(10, 30).difference(zone-offset(8, 0)) is duration(0, 0, 0, 2, 30, 0) zone-offset(10, 30).difference(zone-offset(13, 15)) is duration(0, 0, 0, -23, -45, 0) end
Gets the total ZoneOffset in seconds.
check: zone-offset(10, 45).to-second() is (((10 * 60) + 45) * 60) end
Outputs this ZoneOffset as a String, using an ’+18:00’ format.
check: zone-offset(-8, -30).to-string() is "-08:30" zone-offset(5, 0).to-string() is "+05:00" end
1.4.3 ZoneOffset Functions
Obtains an instance of ZoneOffset using a string representation.
check: offset-to-zone-offset("-1:59") is zone-offset(-1, -59) offset-to-zone-offset("+-8:-60") is ... offset-to-zone-offset("811") raises "ZoneOffset text did not have a sign" offset-to-zone-offset("8:11") raises "ZoneOffset text did not have a sign" offset-to-zone-offset("+811") raises "ZoneOffset text input must be in the form '+18:00'" offset-to-zone-offset("+a:b") raises "ZoneOffset text must have a number for hours" offset-to-zone-offset("+0:b") raises "ZoneOffset text must have a number for minutes" end
Obtains an instance of ZoneOffset using the ZoneId.
check: id-to-zone-offset(GMT) is zone-offset("+", 0, 0) id-to-zone-offset(IST) is zone-offset("+", 5, 30) end
Obtains an instance of ZoneOffset using hours.
check: hours-to-zone-offset(-7) is zone-offset("-", 7, 0) end
1.5 zone-id
1.5.1 The ZoneId Datatype
- | A
- | ACDT
- | ACST
- | ACT
- | ACT
- | ACWST
- | ADT
- | ADT
- | AEDT
- | AEST
- | AET
- | AFT
- | AKDT
- | AKST
- | ALMT
- | AMST
- | AMST
- | AMT
- | AMT
- | ANAST
- | ANAT
- | AQTT
- | ART
- | AST
- | AST
- | AT
- | AWDT
- | AWST
- | AZOST
- | AZOT
- | AZST
- | AoE
- | B
- | BNT
- | BOT
- | BRST
- | BRT
- | BST
- | BST
- | BST
- | BTT
- | C
- | CAST
- | CAT
- | CCT
- | CDT
- | CDT
- | CEST
- | CET
- | CHADT
- | CHAST
- | CHOST
- | CHOT
- | CHUT
- | CIDST
- | CIST
- | CKT
- | CLST
- | CLT
- | COT
- | CST
- | CST
- | CST
- | CT
- | CVT
- | CXT
- | ChST
- | D
- | DAVT
- | DDUT
- | E
- | EASST
- | EAST
- | EAT
- | ECT
- | EDT
- | EEST
- | EET
- | EGST
- | EGT
- | EST
- | ET
- | F
- | FET
- | FJST
- | FJT
- | FKST
- | FKT
- | FNT
- | G
- | GALT
- | GAMT
- | GET
- | GFT
- | GILT
- | GMT
- | GST
- | GST
- | GYT
- | H
- | HDT
- | HKT
- | HOVST
- | HOVT
- | HST
- | I
- | ICT
- | IDT
- | IOT
- | IRDT
- | IRKST
- | IRKT
- | IRST
- | IST
- | IST
- | IST
- | JST
- | K
- | KGT
- | KOST
- | KRAST
- | KRAT
- | KST
- | KUYT
- | L
- | LHDT
- | LHST
- | LINT
- | M
- | MAGST
- | MAGT
- | MART
- | MAWT
- | MDT
- | MHT
- | MMT
- | MSD
- | MSK
- | MST
- | MT
- | MUT
- | MVT
- | MYT
- | N
- | NCT
- | NDT
- | NFDT
- | NFT
- | NOVST
- | NOVT
- | NPT
- | NRT
- | NST
- | NUT
- | NZDT
- | NZST
- | O
- | OMSST
- | OMST
- | P
- | PDT
- | PET
- | PETST
- | PETT
- | PGT
- | PHOT
- | PHT
- | PKT
- | PMDT
- | PMST
- | PONT
- | PST
- | PST
- | PT
- | PWT
- | PYST
- | PYT
- | PYT
- | Q
- | QYZT
- | R
- | RET
- | ROTT
- | S
- | SAKT
- | SAMT
- | SAST
- | SBT
- | SCT
- | SGT
- | SRET
- | SRT
- | SST
- | SYOT
- | T
- | TAHT
- | TFT
- | TJT
- | TKT
- | TLT
- | TMT
- | TOST
- | TOT
- | TRT
- | TVT
- | U
- | ULAST
- | ULAT
- | UTC
- | UYST
- | UYT
- | UZT
- | V
- | VET
- | VLAST
- | VLAT
- | VOST
- | VUT
- | W
- | WAKT
- | WARST
- | WAST
- | WAT
- | WEST
- | WET
- | WFT
- | WGST
- | WGT
- | WIB
- | WIT
- | WITA
- | WST
- | WT
- | X
- | Y
- | YAKST
- | YAKT
- | YAPT
- | YEKST
- | YEKT
- | Z
The ZoneId stores the Time-Zone codes of all ZoneOffsets around the world.
Each code is mapped to a specific offset in a key-value pair dictionary to allow conversion between ZoneId and ZoneOffset, thereby within Temporal objects.
1.5.2 ZoneId Methods
Gets the ZoneOffset of the ZoneId.
check: IST.get-zone-offset() is zone-offset(5, 30) UTC.get-zone-offset() is zone-offset(0, 0) end
Outputs this ZoneId as a String.
check: IST.to-string() is "IST" EST.to-string() is "EST" end
1.5.3 ZoneId Functions
These functions require the ZoneId module to be imported, as indicated in the examples.
Obtains an instance of ZoneId from a String ensuring that the ZoneId is supported.
check: string-to-zone-id("IST") is IST string-to-zone-id("EST") is EST end
Gets the system default ZoneId.
check: nothing is nothing end
1.6 temporal
1.6.1 The Temporal Datatype
- | naive-date(year :: DateTimeYear, month :: DateTimeMonth, day :: DateTimeDay)
- | naive-time(hour :: DateTimeHour, minute :: DateTimeMinute, second :: DateTimeSecond)
- | naive-date-time(year :: DateTimeYear, month :: DateTimeMonth, day :: DateTimeDay, hour :: DateTimeHour, minute :: DateTimeMinute, second :: DateTimeSecond)
- | offset-time(hour :: DateTimeHour, minute :: DateTimeMinute, second :: DateTimeSecond, offset :: ZoneOffset)
- | utc-date-time(year :: DateTimeYear, month :: DateTimeMonth, day :: DateTimeDay, hour :: DateTimeHour, minute :: DateTimeMinute, second :: DateTimeSecond)
- | offset-date-time(year :: DateTimeYear, month :: DateTimeMonth, day :: DateTimeDay, hour :: DateTimeHour, minute :: DateTimeMinute, second :: DateTimeSecond, offset :: ZoneOffset)
- | zoned-date-time(year :: DateTimeYear, month :: DateTimeMonth, day :: DateTimeDay, hour :: DateTimeHour, minute :: DateTimeMinute, second :: DateTimeSecond, zone-id :: ZoneID)
DateTimeYear is any Whole Number
DateTimeMonth is any Integer between 1 and 12 inclusive
DateTimeDay is any Integer between 1 and 31 inclusive
Validation of the day falling in the range of the month’s maximum number of days in the year is enforced when using the DateTime in methods and functions
DateTimeHour is any Integer between 1 and 12 inclusive
DateTimeMinute is any Integer between 0 and 59 inclusive
DateTimeSecond is any Rational within [0, 60)
The Temporal type has several branches, each of which represents a different kind of temporal object, i.e. date, time, or date-time. First, there are three timezone-ignorant branches provided for dates and times, and multiple timezone-aware branches as well. Timezone data is represented in three ways: (a) UTC time, (b) different ZoneOffsets, and (c) ZoneIDs, which will map to specific offsets.
DateTimes with different timezone types are distinct and do not mix, but can be converted to and from each other.
Among other features, these types support: - Addition and subtraction of durations from dates, times, and date-times. - Before/after and equality comparisons among timezone-aware and timezone-ignorant types. - Parsing and formatting operations to and from different representations of datetimes (TODO).
Each of these branches is also associated with a type, thereby allowing type annotations within user programs.
1.6.2 Temporal Attribute Types
type NaiveDate = Temporal%(is-naive-date) type NaiveTime = Temporal%(is-naive-time) type NaiveDateTime = Temporal%(is-naive-date-time)
type UTCDateTime = Temporal%(is-utc-date-time) type UTCDateTimeValid = UTCDateTime%(is-date-time-valid)
type OffsetTime = Temporal%(is-offset-time) type OffsetHour = Number%(is-offset-hour) type OffsetDateTime = Temporal%(is-offset-date-time) type OffsetDateTimeValid = UTCDateTime%(is-date-time-valid)
type ZonedDateTime = Temporal%(is-zoned-date-time)
type DateTimeYear = Number%(is-date-time-year) type DateTimeMonth = Number%(is-date-time-month) type DateTimeDay = Number%(is-date-time-day) type DateTimeHour = Number%(is-date-time-hour) type DateTimeMinute = Number%(is-date-time-minute) type DateTimeSecond = Number%(is-date-time-second)
1.6.3 Temporal Methods
TODO
1.6.4 Temporal Functions
These functions require the Temporal module to be imported, as indicated in the examples.
TODO
1.6.5 naive-date
1.6.5.1 The NaiveDate Datatype
TODO
1.6.5.2 NaiveDate Methods
Combines this date with the time of midnight to create a Temporal%(is-naive-date-time) at the start of this date.
check: 1 is 1 end
Returns a zoned date-time from this date at the earliest valid time according to the rules in the time-zone.‘
check: 1 is 1 end
Combines this date with a time to create a Temporal%(is-naive-date-time).
check: 1 is 1 end
Combines this date with a time to create a Temporal%(is-naive-date-time).
check: 1 is 1 end
Combines this date with an offset time to create an Temporal%(is-offset-date-time).
check: 1 is 1 end
Gets the value of the day unit.
check: 1 is 1 end
"Gets the value of the month unit from 1 to 12."
check: 1 is 1 end
"Gets the value of the year unit."
check: 1 is 1 end
Checks if the year of this date is a leap year, according to the ISO proleptic calendar system rules.
check: 1 is 1 end
Determines whether the current date occurs before the date it is being compared with.
check: 1 is 1 end
Determines whether the current date occurs after the date it is being compared with.
check: 1 is 1 end
Calculates the amount of time until another date.
check: 1 is 1 end
Calculates the duration of days to add to ’other’ to get the date in question.
check: 1 is 1 end
Returns a copy of this date with the specified duration subtracted. (month => 30 days, year => 365 days inside a duration)
check: 1 is 1 end
Returns a copy of this NaiveDate with the specified duration of days subtracted.
check: 1 is 1 end
Returns a copy of this NaiveDate with the specified duration of weeks subtracted.
Returns a copy of this NaiveDate with the specified duration of months subtracted.
check: 1 is 1 end
Returns a copy of this NaiveDate with the specified duration of years subtracted.
check: 1 is 1 end
Returns a copy of this date with the specified duration added. (month => 30 days, year => 365 days inside a duration)
check: 1 is 1 end
Returns a copy of this NaiveDate with the specified duration of days added.
check: 1 is 1 end
Returns a copy of this NaiveDate with the specified duration of weeks added.
Returns a copy of this NaiveDate with the specified duration of months added.
check: 1 is 1 end
Returns a copy of this NaiveDate with the specified duration of years added.
check: 1 is 1 end
Outputs this date as a String, such as 2007-12-03.
check: 1 is 1 end
Returns the number of days remaining in a year.
check: 1 is 1 end
Returns the number of days that have occurred in a year so far.
check: 1 is 1 end
Returns a copy of this date with the specified unit set to a new value.
check: 1 is 1 end
Returns a copy of this NaiveDate with the day-of-month altered.
check: 1 is 1 end
Returns a copy of this NaiveDate with the month value altered.
check: 1 is 1 end
Returns a copy of this NaiveDate with the year value altered.
check: 1 is 1 end
Returns a copy of this NaiveDate with the day incremented by 1.
check: 1 is 1 end
Returns a copy of this NaiveDate with the day decreased by 1.
check: 1 is 1 end
1.6.6 naive-time
1.6.6.1 NaiveTime Methods
Combines this time with a date to create a Temporal%(is-naive-date-time).
check: 1 is 1 end
Combines this time with an offset to create an Temporal%(is-offset-time).
check: 1 is 1 end
Gets the value of the seconds unit.
check: 1 is 1 end
Gets the value of the minutes unit.
check: 1 is 1 end
Gets the value of the hours unit.
check: 1 is 1 end
Checks if this Temporal%(is-naive-time) is after the specified Temporal%(is-naive-time).
check: 1 is 1 end
Checks if this Temporal%(is-naive-time) is before the specified Temporal%(is-naive-time).
check: 1 is 1 end
Returns a copy of this time with the specified amount subtracted.
check: 1 is 1 end
Returns a copy of this time with the specified number of seconds subtracted.
check: 1 is 1 end
Returns a copy of this time with the specified number of minutes subtracted.
check: 1 is 1 end
Returns a copy of this time with the specified number of hours subtracted.
check: 1 is 1 end
Returns a copy of this time with the specified amount added.
check: 1 is 1 end
Returns a copy of this time with the specified number of seconds added.
check: 1 is 1 end
Returns a copy of this time with the specified number of minutes added.
check: 1 is 1 end
Returns a copy of this time with the specified number of hours added.
check: 1 is 1 end
Outputs this time as a String, such as 10:15:30
check: 1 is 1 end
Extracts the time as seconds of day, from 0 to 24 * 60 * 60 - 1.
check: 1 is 1 end
Calculates the normalized duration of time until another time.
check: 1 is 1 end
Returns a copy of this time with the specified unit set to a new value.
check: 1 is 1 end
Returns a copy of this temporal with the seconds altered.
check: 1 is 1 end
Returns a copy of this temporal with the minutes altered.
check: 1 is 1 end
Returns a copy of this temporal with the hours altered.
check: 1 is 1 end
1.6.6.2 NaiveTime Functions
These functions require the Temporal module to be imported, as indicated in the examples.
- naive-time-of-any :: (
- hour :: Number,
- month :: Number,
- day :: Number
- )
- -> NaiveTime
Obtains an instance of NaiveTime from a year, month and day.
import temporal as T check: 1 is 1 end
Obtains the current time from the system clock in the default time-zone.
import temporal as T check: 1 is 1 end
Obtains the current time from the system clock in the specified time-zone.
import temporal as T check: 1 is 1 end
Obtains an instance of Temporal%(is-naive-time) from a text string such as 23:59:59
import temporal as T check: 1 is 1 end
1.6.7 utc-date-time
1.6.7.1 The UTCDateTime Type
type UTCDateTime = Temporal%(is-utc-date-time)
UTCDateTime info...
UTCDateTime must always be valid, where a valid UTCDateTime has rational seconds within [0, 60), integer minutes within [0, 60), integer hours within [0, 24), days between 1 (inclusive) and the valid number of days for the appropriate month of the appropriate year, integer months within [0, 12], and whole number year
1.6.7.2 UTCDateTime Methods
Combines this date-time with an offset to create an OffsetDateTime.
check: 1 is 1 end
Combines this date-time with a time-zone to create a ZonedDateTime.
check: 1 is 1 end
Gets the NaiveDate from the date time.
check: 1 is 1 end
Gets the NaiveTime from the date time.
check: 1 is 1 end
Returns 1 if this UTCDateTime is before the other, 0 if both contain the same date-time, -1 if the other is before this UTCDateTime.
check: 1 is 1 end
Checks if the year is a leap year, according to the ISO proleptic calendar system rules.
check: 1 is 1 end
Returns a copy of this UTCDateTime with the specified amount added.
check: 1 is 1 end
Returns a copy of this temporal with the specified number of weeks added."
check: 1 is 1 end
Returns a copy of this UTCDateTime with the specified amount subtracted.
check: 1 is 1 end
Returns a copy of this temporal with the specified number of weeks subtracted."
check: 1 is 1 end
Calculates the duration of time until another UTCDateTime.
check: 1 is 1 end
Outputs this date-time as a String, such as 2007-12-03T10:15:30.
check: 1 is 1 end
Returns a copy of this UTCDateTime with the specified unit set to a new value.
The UTCDateTime is also normalized internally so that even if a negative or ’invalid’ value (such as 31 days in February) is passed, a valid, equivalent UTCDateTime will be returned
check: 1 is 1 end
1.6.7.3 UTCDateTime Functions
Obtains an instance of UTCDateTime from a text string such as ’2007-12-03T10:15:30’.
check: 1 is 1 end
1.6.8 offset-time
Offset Hour is any Integer that must be between (inclusive) -12 and 14
1.6.8.1 OffsetTime Methods
Combines this time with a date to create a Temporal%(is-offset-date-time).
check: 1 is 1 end
Combines this time with an offset to create an Temporal%(is-offset-time).
check: 1 is 1 end
Gets the value of the seconds unit.
check: 1 is 1 end
Gets the value of the minutes unit.
check: 1 is 1 end
Gets the value of the hours unit.
check: 1 is 1 end
Gets the NaiveTime component from the OffsetTime in question.
check: 1 is 1 end
Returns an OffsetTime with the time component representing the equivalent time in UTC and the ZoneOffset set to zero.
check: 1 is 1 end
Returns a copy of this OffsetTime with an offset of zero magnitude ensuring that the result has the same naive time.
check: 1 is 1 end
Checks if this Temporal%(is-offset-time) is after the specified Temporal%(is-offset-time).
check: 1 is 1 end
Checks if this Temporal%(is-offset-time) is before the specified Temporal%(is-offset-time).
check: 1 is 1 end
Returns a copy of this OffsetTime with the specified amount subtracted.
check: 1 is 1 end
Returns a copy of this OffsetTime with the specified number of seconds subtracted.
check: 1 is 1 end
Returns a copy of this OffsetTime with the specified number of minutes subtracted.
check: 1 is 1 end
Returns a copy of this OffsetTime with the specified number of hours subtracted.
check: 1 is 1 end
Returns a copy of this OffsetTime with the specified amount added.
check: 1 is 1 end
Returns a copy of this OffsetTime with the specified number of seconds added.
check: 1 is 1 end
Returns a copy of this OffsetTime with the specified number of minutes added.
check: 1 is 1 end
Returns a copy of this OffsetTime with the specified number of hours added.
check: 1 is 1 end
Outputs this time as a String, such as 10:15:30+00:30.
check: 1 is 1 end
Extracts the time as seconds of day, from 0 to 24 * 60 * 60 - 1.
check: 1 is 1 end
Calculates the normalized duration of time until another OffsetTime.
check: 1 is 1 end
Returns a copy of this time with the specified unit set to a new value.
check: 1 is 1 end
Returns a copy of this OffsetTime with the seconds altered.
check: 1 is 1 end
Returns a copy of this OffsetTime with the minutes altered.
check: 1 is 1 end
Returns a copy of this OffsetTime with the hours altered.
check: 1 is 1 end
1.6.9 offset-date-time
1.6.9.1 The OffsetDateTime Type
type OffsetDateTime = Temporal%(is-offset-date-time)
OffsetDateTime info...
OffsetDateTime must always be valid, where a valid OffsetDateTime has rational seconds within [0, 60), integer minutes within [0, 60), integer hours within [0, 24), days between 1 (inclusive) and the valid number of days for the appropriate month of the appropriate year, integer months within [0, 12], and whole number year
An OffsetDateTime must also have a valid offset following the validity rules described for ZoneOffset in the OffsetTime Section
1.6.9.2 OffsetDateTime Methods
Extracts the date time and converts into a NaiveDateTime.
check: 1 is 1 end
Converts the date time into that at UTC.
check: 1 is 1 end
Combines this date-time with an offset to create an OffsetDateTime ensuring that the result has the same UTCDateTime.
check: 1 is 1 end
Combines this date-time with an offset to create an OffsetDateTime trying to keep the same naive date and time.
check: 1 is 1 end
Combines this date-time with a time-zone to create a ZonedDateTime ensuring that the result has the same UTCDateTime.
check: 1 is 1 end
Combines this date-time with a time-zone to create a ZonedDateTime trying to keep the same naive date and time.
check: 1 is 1 end
Gets the NaiveDate from the date time.
check: 1 is 1 end
Gets the NaiveTime from the date time.
check: 1 is 1 end
Returns 1 if this OffsetDateTime is before the other, 0 if both contain the same date-time, -1 if the other is before this OffsetDateTime.
check: 1 is 1 end
Checks if the year is a leap year, according to the ISO proleptic calendar system rules.
check: 1 is 1 end
Returns a copy of this OffsetDateTime with the specified amount added.
check: 1 is 1 end
Returns a copy of this temporal with the specified number of weeks added."
check: 1 is 1 end
Returns a copy of this OffsetDateTime with the specified amount subtracted.
check: 1 is 1 end
Returns a copy of this temporal with the specified number of weeks subtracted."
check: 1 is 1 end
Calculates the duration of time until another OffsetDateTime.
check: 1 is 1 end
Outputs this date-time as a String, such as 2007-12-03T10:15:30.
check: 1 is 1 end
Returns a copy of this OffsetDateTime with the specified unit set to a new value.
The OffsetDateTime is also normalized internally so that even if a negative or ’invalid’ value (such as 31 days in February) is passed, a valid, equivalent OffsetDateTime will be returned
check: 1 is 1 end
1.6.9.3 OffsetDateTime Functions
Obtains an instance of OffsetDateTime from a text string such as ’2007-12-03T10:15:30+05:00’.
check: 1 is 1 end