zutempo: Dates, Times and Durations Following 'JavaScript' Temporal
Source:R/zutempo-package.R
zutempo-package.RdAn implementation of the Temporal date and time model of 'ECMAScript', the language standard 'ECMA-262' behind 'JavaScript', in 'R', with a native 'C' core: 'Instant', 'ZonedDateTime', 'PlainDateTime', 'PlainDate', 'PlainTime', 'PlainYearMonth', 'PlainMonthDay', 'Duration' and 'Now', in the ISO 8601 calendar, with the time zones of the Internet Assigned Numbers Authority (IANA) read from the same database that base 'R' uses. Values are stored exactly in 'R' vectors, arithmetic is done over the specification's full ranges with exact 128-bit intermediates, and strings follow the Internet Extended Date/Time Format of RFC 9557, with annotations. Every result is meant to match the result of the same operation in a browser or in 'Node.js'.
Scope
zutempo implements every member of the eight Temporal types and
Temporal.Now in the pinned specification (zutempo_info()), in the
ISO 8601 calendar. It does not include:
calendars other than ISO 8601 (Hebrew, Japanese and the others come from ECMA-402, with CLDR data);
locale formatting (
toLocaleString()): convert toPOSIXctand use base R'sformat();custom time zones, or POSIX TZ strings as zone identifiers;
arithmetic and comparison operators on dates and times (
x + d,x < y,x == y): they raise azutempo_type_error. Use the functions, such astemporal_add(),temporal_equals()andplain_date_compare(). Durations do compare with==and<.
sort(), order(), min(), max() and range() use each type's
compare() order; a zoned value sorts by its instant. A
plain_month_day() has no compare() in Temporal: it sorts by month and
day, but has no min(), max() or range().
rank() compares with operators, so use rank(xtfrm(x)).
Author
Maintainer: Pedro Baltazar pedrobtz@gmail.com [copyright holder]
Authors:
Pedro Baltazar pedrobtz@gmail.com [copyright holder]
Other contributors:
Ecma International (Test262 tests translated into tests/testthat/test262/, see inst/COPYRIGHTS) [copyright holder]