hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 6dd66f750cbdc277accbfe99d8af4a0514796a3d
parent 55833e711d310b7be3658b77f27d2ca1bb7be152
Author: Byron Torres <b@torresjrjr.com>
Date:   Sat, 13 May 2023 02:38:19 +0100

time::date: rename datetime type to date

Hare code shall now use the shorter and terser `date::date` instead of
the legacy `datetime::datetime`. By convention, the "date" noun is now
reserved for a general date that a chronology implements. As such,
`date::date` is the general date type of the Gregorian chronology.

Diffstat:
Mtime/chrono/README | 2+-
Mtime/date/README | 28+++++++++++++---------------
Mtime/date/arithmetic.ha | 12++++++------
Mtime/date/chronology.ha | 84++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mtime/date/datetime.ha | 52++++++++++++++++++++++++++--------------------------
Mtime/date/duration.ha | 4++--
Mtime/date/errors.ha | 8++++----
Mtime/date/format.ha | 16++++++++--------
Mtime/date/reckon.ha | 4++--
Mtime/date/timezone.ha | 4++--
Mtime/date/virtual.ha | 22+++++++++++-----------
11 files changed, 117 insertions(+), 119 deletions(-)

diff --git a/time/chrono/README b/time/chrono/README @@ -13,7 +13,7 @@ certain chronological values according to its [[locality]]. The "observe" functions [[date]], [[time]], and [[zone]] obtain these values. Higher level modules like [[time::date]] expand upon this with more complex -chronological values (years, hours, etc.). The [[time::date::datetime]] type +chronological values (years, hours, etc.). The [[time::date::date]] type embeds [[moment]], and other modules implementing other chronologies may interoperate with their own extension types. diff --git a/time/date/README b/time/date/README @@ -1,35 +1,33 @@ The time::date module implements the common international Gregorian chronology, based on the astronomically numbered proleptic Gregorian calendar, as per ISO -8601, and the common 24 hour clock. It provides [[datetime]], a representation -of civil date/time and an extension of the [[time::chrono::moment]] type, +8601, and the common 24 hour clock. It provides [[date]], a representation of +civil date/time, and an extension of the [[time::chrono::moment]] type, optimized for dealing with the Gregorian chronology. The [[time::chrono]] module has many useful functions which interoperate with -datetimes. Any [[time::chrono]] function which accepts *moment also accepts -*datetime. +dates. Any [[time::chrono]] function which accepts *moment also accepts *date. -Datetimes are created with [[new]], [[now]], or one of the "from_" functions. -Alternatively, use the [[virtual]] interface to construct a datetime. +Dates are created with [[new]], [[now]], or one of the "from_" functions. +Alternatively, use the [[virtual]] interface to construct a date. The [[virtual]] interface, coupled with the [[realize]] function, provides a way -to handle uncertain or invalid datetime information intermediately, transform +to handle uncertain or invalid date/time information intermediately, transform date/time values with arithmetic, [[parse]] date/time strings, and construct new -datetimes safely. +dates safely. -The "observe" functions accept a *datetime and evaluates one of its observed +The "observe" functions accept a *date and evaluates one of its observed chronological values. This includes [[year]], [[month]], [[day]], [[hour]] etc. -[[datetime]]s may be localized to different [[time::chrono::locality]]s via the -[[in]] function. The "observe" functions will evaluate the correct values -accordingly. You'll find a standard selection of world timezones in the -[[time::chrono]] module. +Dates may be localized to different [[time::chrono::locality]]s via the [[in]] +function. The "observe" functions will evaluate the correct values accordingly. +You'll find a standard selection of world timezones in [[time::chrono]]. See [[parse]] and [[format]] for working with date/time strings. -Timescale-wise datetime arithmetic using the [[time::duration]] type is possible, +Timescale-wise date arithmetic using the [[time::duration]] type is possible, with [[add]] and [[time::chrono::diff]]. -Chronology-wise datetime arithmetic using the [[period]] type is possible, with +Chronology-wise date arithmetic using the [[period]] type is possible, with [[reckon]] and the [[calculus]] type, [[pdiff]], [[unitdiff]], and [[truncate]]. Note that chronological and calendrical arithmetic is highly irregular due to overflows and timezone discontinuities, so think carefully about what you want. diff --git a/time/date/arithmetic.ha b/time/date/arithmetic.ha @@ -21,11 +21,11 @@ export type unit = enum int { NANOSECOND, }; -// Calculates the [[period]] between two [[datetime]]s, from A to B. +// Calculates the [[period]] between two [[date]]s, from A to B. // The returned period, provided to [[reckon]] along with A, will produce B, // regardless of the [[calculus]] used. All the period's non-zero fields will // have the same sign. -export fn pdiff(a: datetime, b: datetime) period = { +export fn pdiff(a: date, b: date) period = { let p = period { ... }; if (chrono::compare(&a, &b) == 0) { @@ -94,8 +94,8 @@ export fn pdiff(a: datetime, b: datetime) period = { return if (reverse) neg(p) else p; }; -// Calculates the nominal [[unit]] difference between two [[datetime]]s. -export fn unitdiff(a: datetime, b: datetime, u: unit) i64 = { +// Calculates the nominal [[unit]] difference between two [[date]]s. +export fn unitdiff(a: date, b: date, u: unit) i64 = { switch (u) { case unit::ERA => return era(&b) - era(&a); @@ -119,11 +119,11 @@ export fn unitdiff(a: datetime, b: datetime, u: unit) i64 = { }; }; -// Truncates the given [[datetime]] at the provided nominal [[unit]]. +// Truncates the given [[date]] at the provided nominal [[unit]]. // // For example, truncating to the nearest unit::MONTH will set the 'day', // 'hour', 'minute', 'second', and 'nanosecond' fields to their minimum values. -export fn truncate(dt: datetime, u: unit) datetime = { +export fn truncate(dt: date, u: unit) date = { // TODO: There exist timezones where midnight is invalid on certain // days. The new()! calls will fail, but we probably don't want to '?' // propagate [[invalid]] to keep this function's use simple. The minimum diff --git a/time/date/chronology.ha b/time/date/chronology.ha @@ -7,49 +7,49 @@ use time::chrono; // These functions are renamed to avoid namespace conflicts, like in the // parameters of the [[new]] function. -// Returns a [[datetime]]'s era. -export fn era(dt: *datetime) int = _era(dt); +// Returns a [[date]]'s era. +export fn era(dt: *date) int = _era(dt); -// Returns a [[datetime]]'s year. -export fn year(dt: *datetime) int = _year(dt); +// Returns a [[date]]'s year. +export fn year(dt: *date) int = _year(dt); -// Returns a [[datetime]]'s month of the year. -export fn month(dt: *datetime) int = _month(dt); +// Returns a [[date]]'s month of the year. +export fn month(dt: *date) int = _month(dt); -// Returns a [[datetime]]'s day of the month. -export fn day(dt: *datetime) int = _day(dt); +// Returns a [[date]]'s day of the month. +export fn day(dt: *date) int = _day(dt); -// Returns a [[datetime]]'s day of the week; Monday=0 to Sunday=6. -export fn weekday(dt: *datetime) int = _weekday(dt); +// Returns a [[date]]'s day of the week; Monday=0 to Sunday=6. +export fn weekday(dt: *date) int = _weekday(dt); -// Returns a [[datetime]]'s ordinal day of the year. -export fn yearday(dt: *datetime) int = _yearday(dt); +// Returns a [[date]]'s ordinal day of the year. +export fn yearday(dt: *date) int = _yearday(dt); -// Returns a [[datetime]]'s ISO week-numbering year. -export fn isoweekyear(dt: *datetime) int = _isoweekyear(dt); +// Returns a [[date]]'s ISO week-numbering year. +export fn isoweekyear(dt: *date) int = _isoweekyear(dt); -// Returns a [[datetime]]'s Gregorian week starting Monday. -export fn week(dt: *datetime) int = _week(dt); +// Returns a [[date]]'s Gregorian week starting Monday. +export fn week(dt: *date) int = _week(dt); -// Returns a [[datetime]]'s Gregorian week starting Sunday. -export fn sundayweek(dt: *datetime) int = _sundayweek(dt); +// Returns a [[date]]'s Gregorian week starting Sunday. +export fn sundayweek(dt: *date) int = _sundayweek(dt); -// Returns a [[datetime]]'s ISO week. -export fn isoweek(dt: *datetime) int = _isoweek(dt); +// Returns a [[date]]'s ISO week. +export fn isoweek(dt: *date) int = _isoweek(dt); -// Returns a [[datetime]]'s hour of the day. -export fn hour(dt: *datetime) int = _hour(dt); +// Returns a [[date]]'s hour of the day. +export fn hour(dt: *date) int = _hour(dt); -// Returns a [[datetime]]'s minute of the hour. -export fn minute(dt: *datetime) int = _minute(dt); +// Returns a [[date]]'s minute of the hour. +export fn minute(dt: *date) int = _minute(dt); -// Returns a [[datetime]]'s second of the minute. -export fn second(dt: *datetime) int = _second(dt); +// Returns a [[date]]'s second of the minute. +export fn second(dt: *date) int = _second(dt); -// Returns a [[datetime]]'s nanosecond of the second. -export fn nanosecond(dt: *datetime) int = _nanosecond(dt); +// Returns a [[date]]'s nanosecond of the second. +export fn nanosecond(dt: *date) int = _nanosecond(dt); -fn _era(dt: *datetime) int = { +fn _era(dt: *date) int = { match (dt.era) { case void => if (dt.year is void) { @@ -62,7 +62,7 @@ fn _era(dt: *datetime) int = { }; }; -fn _year(dt: *datetime) int = { +fn _year(dt: *date) int = { match (dt.year) { case void => const ymd = calc_ymd(chrono::date(dt)); @@ -75,7 +75,7 @@ fn _year(dt: *datetime) int = { }; }; -fn _month(dt: *datetime) int = { +fn _month(dt: *date) int = { match (dt.month) { case void => const ymd = calc_ymd(chrono::date(dt)); @@ -88,7 +88,7 @@ fn _month(dt: *datetime) int = { }; }; -fn _day(dt: *datetime) int = { +fn _day(dt: *date) int = { match (dt.day) { case void => const ymd = calc_ymd(chrono::date(dt)); @@ -101,7 +101,7 @@ fn _day(dt: *datetime) int = { }; }; -fn _weekday(dt: *datetime) int = { +fn _weekday(dt: *date) int = { match (dt.weekday) { case void => dt.weekday = calc_weekday(chrono::date(dt)); @@ -111,7 +111,7 @@ fn _weekday(dt: *datetime) int = { }; }; -fn _yearday(dt: *datetime) int = { +fn _yearday(dt: *date) int = { match (dt.yearday) { case void => if (dt.year is void) { @@ -134,7 +134,7 @@ fn _yearday(dt: *datetime) int = { }; }; -fn _isoweekyear(dt: *datetime) int = { +fn _isoweekyear(dt: *date) int = { match (dt.isoweekyear) { case void => if (dt.year is void) { @@ -161,7 +161,7 @@ fn _isoweekyear(dt: *datetime) int = { }; }; -fn _week(dt: *datetime) int = { +fn _week(dt: *date) int = { match (dt.week) { case void => if (dt.yearday is void) { @@ -180,7 +180,7 @@ fn _week(dt: *datetime) int = { }; }; -fn _sundayweek(dt: *datetime) int = { +fn _sundayweek(dt: *date) int = { match (dt.sundayweek) { case void => if (dt.yearday is void) { @@ -199,7 +199,7 @@ fn _sundayweek(dt: *datetime) int = { }; }; -fn _isoweek(dt: *datetime) int = { +fn _isoweek(dt: *date) int = { match (dt.isoweek) { case void => if (dt.year is void) { @@ -218,7 +218,7 @@ fn _isoweek(dt: *datetime) int = { }; }; -fn _hour(dt: *datetime) int = { +fn _hour(dt: *date) int = { match (dt.hour) { case void => const hmsn = calc_hmsn(chrono::time(dt)); @@ -232,7 +232,7 @@ fn _hour(dt: *datetime) int = { }; }; -fn _minute(dt: *datetime) int = { +fn _minute(dt: *date) int = { match (dt.minute) { case void => const hmsn = calc_hmsn(chrono::time(dt)); @@ -246,7 +246,7 @@ fn _minute(dt: *datetime) int = { }; }; -fn _second(dt: *datetime) int = { +fn _second(dt: *date) int = { match (dt.second) { case void => const hmsn = calc_hmsn(chrono::time(dt)); @@ -260,7 +260,7 @@ fn _second(dt: *datetime) int = { }; }; -fn _nanosecond(dt: *datetime) int = { +fn _nanosecond(dt: *date) int = { match (dt.nanosecond) { case void => const hmsn = calc_hmsn(chrono::time(dt)); diff --git a/time/date/datetime.ha b/time/date/datetime.ha @@ -5,7 +5,7 @@ use errors; use time; use time::chrono; -// Invalid [[datetime]]. +// Invalid [[date]]. export type invalid = !chrono::invalid; // A date/time object; a [[time::chrono::moment]] wrapper optimized for the @@ -19,14 +19,14 @@ export type invalid = !chrono::invalid; // interrogating the fields' type and value (e.g. using match statements) is // also improper. // -// A datetime observes various chronological values, cached in its fields. To +// A date observes various chronological values, cached in its fields. To // evaluate and obtain these values, use the various "observe" functions // ([[year]], [[day]], etc.). These values are derived from the embedded moment // information, and thus are guaranteed to be valid. // // See [[virtual]] for an public, mutable, intermediary representation of a -// datetime, which waives guarantees of validity. -export type datetime = struct { +// date, which waives guarantees of validity. +export type date = struct { chrono::moment, era: (void | int), @@ -46,7 +46,7 @@ export type datetime = struct { nanosecond: (void | int), }; -fn init() datetime = datetime { +fn init() date = date { sec = 0, nsec = 0, loc = chrono::UTC, @@ -71,8 +71,8 @@ fn init() datetime = datetime { nanosecond = void, }; -// Evaluates and populates all of a [[datetime]]'s fields. -fn all(dt: *datetime) *datetime = { +// Evaluates and populates all of a [[date]]'s fields. +fn all(dt: *date) *date = { _era(dt); _year(dt); _month(dt); @@ -92,7 +92,7 @@ fn all(dt: *datetime) *datetime = { return dt; }; -// Creates a new datetime. A maximum of 7 optional field arguments can be given: +// Creates a new [[date]]. A maximum of 7 optional field arguments can be given: // year, month, day-of-month, hour, minute, second, nanosecond. 8 or more causes // an abort. // @@ -117,7 +117,7 @@ fn all(dt: *datetime) *datetime = { // You may omit the zoff. If the givem timezone has a single zone, [[new]] // will use that zone's zoff. Otherwise [[new]] will try to infer the zoff // from the multiple zones. This will fail during certain timezone transitions, -// where certain datetimes are ambiguous or nonexistent. For example: +// where certain dates are ambiguous or nonexistent. For example: // // - In the Europe/Amsterdam timezone, at 1995 March 26th, // the local time 02:30 was never observed, @@ -130,7 +130,7 @@ export fn new( loc: chrono::locality, zo: (time::duration | void), fields: int... -) (datetime | invalid) = { +) (date | invalid) = { // TODO: // - revise examples // - Implement as described. @@ -195,20 +195,20 @@ export fn new( return dt; }; -// Returns a [[datetime]] of the current system time using +// Returns a [[date]] of the current system time using // [[time::clock::REALTIME]], in the [[time::chrono::LOCAL]] locality. -export fn now() datetime = { +export fn now() date = { return from_instant(chrono::LOCAL, time::now(time::clock::REALTIME)); }; -// Returns a [[datetime]] of the current system time using +// Returns a [[date]] of the current system time using // [[time::clock::REALTIME]], in the [[time::chrono::UTC]] locality. -export fn nowutc() datetime = { +export fn nowutc() date = { return from_instant(chrono::UTC, time::now(time::clock::REALTIME)); }; -// Creates a [[datetime]] from a [[time::chrono::moment]]. -export fn from_moment(m: chrono::moment) datetime = { +// Creates a [[date]] from a [[time::chrono::moment]]. +export fn from_moment(m: chrono::moment) date = { const dt = init(); dt.loc = m.loc; dt.sec = m.sec; @@ -219,13 +219,13 @@ export fn from_moment(m: chrono::moment) datetime = { return dt; }; -// Creates a [[datetime]] from a [[time::instant]] +// Creates a [[date]] from a [[time::instant]] // in a [[time::chrono::locality]]. -export fn from_instant(loc: chrono::locality, i: time::instant) datetime = { +export fn from_instant(loc: chrono::locality, i: time::instant) date = { return from_moment(chrono::new(loc, i)); }; -// Creates a [[datetime]] from a string, parsed according to a layout format. +// Creates a [[date]] from a string, parsed according to a layout format. // See [[parse]] and [[format]]. At least a complete calendar date has to be // provided. The if hour, minute, second, nanosecond, or zone offset are not // provided, they default to 0. @@ -236,7 +236,7 @@ export fn from_instant(loc: chrono::locality, i: time::instant) datetime = { // locs... // )!; // -// The datetime's [[time::chrono::locality]] will be selected from the provided +// The date's [[time::chrono::locality]] will be selected from the provided // locality arguments. The 'name' field of these localities will be matched // against the parsed result for the %L specifier. If %L is not specified, or if // no locality is provided, [[time::chrono::UTC]] is used. @@ -244,7 +244,7 @@ export fn from_str( layout: str, s: str, locs: time::chrono::locality... -) (datetime | parsefail | insufficient | invalid) = { +) (date | parsefail | insufficient | invalid) = { const v = newvirtual(); v.zoff = 0; v.hour = 0; @@ -259,7 +259,7 @@ export fn from_str( const amst = chrono::tz("Europe/Amsterdam")!; defer chrono::timezone_free(amst); - let testcases: [_](str, str, []chrono::locality, (datetime | error)) = [ + let testcases: [_](str, str, []chrono::locality, (date | error)) = [ (STAMP_NOZL, "2001-02-03 15:16:17.123456789 +0000 UTC UTC", [], new(chrono::UTC, 0, 2001, 2, 3, 15, 16, 17, 123456789)!), (STAMP, "2001-02-03 15:16:17", [], @@ -290,10 +290,10 @@ export fn from_str( const actual = from_str(t.0, t.1, t.2...); match (expect) { - case let e: datetime => - assert(actual is datetime, "wanted 'datetime', got 'error'"); - assert(chrono::eq(&(actual as datetime), &e)!, - "incorrect 'datetime' value"); + case let e: date => + assert(actual is date, "wanted 'date', got 'error'"); + assert(chrono::eq(&(actual as date), &e)!, + "incorrect 'date' value"); case let e: parsefail => assert(actual is parsefail, "wanted 'parsefail', got other"); diff --git a/time/date/duration.ha b/time/date/duration.ha @@ -2,10 +2,10 @@ // (c) 2023 Byron Torres <b@torresjrjr.com> use time; -// Adds a [[time::duration]] to a [[datetime]] with [[time::add]]. +// Adds a [[time::duration]] to a [[date]] with [[time::add]]. // // See [[reckon]] for a chronology-wise arithmetic operation which uses // [[period]]. -export fn add(a: datetime, d: time::duration) datetime = { +export fn add(a: date, d: time::duration) date = { return from_instant(a.loc, time::add(*(&a: *time::instant), d)); }; diff --git a/time/date/errors.ha b/time/date/errors.ha @@ -1,18 +1,18 @@ // License: MPL-2.0 // (c) 2023 Byron Torres <b@torresjrjr.com> -// All possible errors returned from [[datetime]]. +// All possible errors returned from [[date]]. export type error = !(insufficient | invalid | parsefail); // Converts an [[error]] into a human-friendly string. export fn strerror(err: error) const str = { match (err) { case insufficient => - return "Insufficient datetime information"; + return "Insufficient date information"; case invalid => - return "Invalid datetime information"; + return "Invalid date information"; case let rn: parsefail => // TODO: use rune 'rn' here - return "Datetime parsing error"; + return "Date parsing error"; }; }; diff --git a/time/date/format.ha b/time/date/format.ha @@ -74,34 +74,34 @@ def MONTHS_SHORT: [_]str = [ "Oct", "Nov", "Dec", ]; -// TODO: Make format() accept parameters of type (datetime | period), using the +// TODO: Make format() accept parameters of type (date | period), using the // "intervals" standard representation provided by ISO 8601? // // See https://en.wikipedia.org/wiki/ISO_8601#Time_intervals // // Ticket: https://todo.sr.ht/~sircmpwn/hare/650 -// Formats a [[datetime]] and writes it into a caller supplied buffer. +// Formats a [[date]] and writes it into a caller supplied buffer. // The returned string is borrowed from this buffer. export fn bsformat( buf: []u8, layout: str, - dt: *datetime, + dt: *date, ) (str | io::error) = { let sink = strio::fixed(buf); format(&sink, layout, dt)?; return strio::string(&sink); }; -// Formats a [[datetime]] and writes it into a heap-allocated string. +// Formats a [[date]] and writes it into a heap-allocated string. // The caller must free the return value. -export fn asformat(layout: str, dt: *datetime) (str | io::error) = { +export fn asformat(layout: str, dt: *date) (str | io::error) = { let sink = strio::dynamic(); format(&sink, layout, dt)?; return strio::string(&sink); }; -fn fmtout(out: io::handle, r: rune, dt: *datetime) (size | io::error) = { +fn fmtout(out: io::handle, r: rune, dt: *date) (size | io::error) = { switch (r) { case 'a' => return fmt::fprint(out, WEEKDAYS_SHORT[_weekday(dt)]); @@ -166,7 +166,7 @@ fn fmtout(out: io::handle, r: rune, dt: *datetime) (size | io::error) = { }; }; -// Formats a [[datetime]] according to a layout and writes to an [[io::handle]]. +// Formats a [[date]] according to a layout and writes to an [[io::handle]]. // // The layout may contain any of the following format specifiers listed below. // Implemented are a subset of the POSIX strftime(3) format specifiers, as well @@ -206,7 +206,7 @@ fn fmtout(out: io::handle, r: rune, dt: *datetime) (size | io::error) = { export fn format( h: io::handle, layout: str, - dt: *datetime + dt: *date ) (size | io::error) = { const iter = strings::iter(layout); let escaped = false; diff --git a/time/date/reckon.ha b/time/date/reckon.ha @@ -49,7 +49,7 @@ export type calculus = enum uint { FOLD = 1 << 4, }; -// Reckons from a given [[datetime]] to a new one, via a set of [[period]]s. +// Reckons from a given [[date]] to a new one, via a set of [[period]]s. // This is a chronology-wise arithmetic operation. Each period is reckoned // independently in succession, applying (adding) their units from most to least // significant. @@ -69,7 +69,7 @@ export type calculus = enum uint { // // See [[add]] for a timescale-wise arithmetic operation which uses // [[time::duration]]. -export fn reckon(dt: datetime, calc: calculus, ps: period...) datetime = { +export fn reckon(dt: date, calc: calculus, ps: period...) date = { let r = newvirtual(); // our reckoner r.vloc = dt.loc; r.zoff = chrono::mzone(&dt).zoff; diff --git a/time/date/timezone.ha b/time/date/timezone.ha @@ -4,10 +4,10 @@ use time; use time::chrono; -// Creates an equivalent [[datetime]] with a different +// Creates an equivalent [[date]] with a different // [[time::chrono::locality]]. // // The [[time::chrono::discontinuity]] rules from [[time::chrono::in]] apply here. -export fn in(loc: chrono::locality, dt: datetime) (datetime | chrono::discontinuity) = { +export fn in(loc: chrono::locality, dt: date) (date | chrono::discontinuity) = { return from_moment(chrono::in(loc, *(&dt: *chrono::moment))?); }; diff --git a/time/date/virtual.ha b/time/date/virtual.ha @@ -3,20 +3,20 @@ use time; use time::chrono; -// A [[virtual]] has insufficient information and cannot create a valid datetime. +// A [[virtual]] does not have enough information to create a valid [[date]]. export type insufficient = !void; -// A virtual datetime; a [[datetime]] wrapper interface, which represents a -// datetime of uncertain validity. Its fields need not be valid observed -// chronological values. It is meant as an intermediary container for datetime -// information to be resolved with the [[realize]] function. +// A virtual date; a [[date]] wrapper interface, which represents a date of +// uncertain validity. Its fields need not be valid observed chronological +// values. It is meant as an intermediary container for date information to be +// resolved with the [[realize]] function. // -// Unlike [[datetime]], a virtual's fields are meant to be treated as public and +// Unlike [[date]], a virtual's fields are meant to be treated as public and // mutable. The embedded [[time::instant]] and [[time::chrono::locality]] fields // (.sec .nsec .loc) are considered meaningless. Behaviour with the "observe" // functions is undefined. // -// This can be used to construct a new [[datetime]] piece-by-piece. Start with +// This can be used to construct a new [[date]] piece-by-piece. Start with // [[newvirtual]], then collect enough date/time information incrementally by // direct field assignments and/or with [[parse]]. Finish with [[realize]]. // @@ -31,7 +31,7 @@ export type insufficient = !void; // let dt = date::realize(v)!; // export type virtual = struct { - datetime, + date, // virtual's locality vloc: (void | time::chrono::locality), // locality name @@ -79,7 +79,7 @@ export fn newvirtual() virtual = virtual { ampm = void, }; -// Realizes a valid [[datetime]] from a [[virtual]], or fails appropriately. +// Realizes a valid [[date]] from a [[virtual]], or fails appropriately. // Four values require determination. Each has various determination strategies, // each of which use a certain set of non-void fields from the given virtual. // The following determination strategies will be attempted in order. @@ -111,12 +111,12 @@ export fn newvirtual() virtual = virtual { // Defaults to [[time::chrono::UTC]]. // // If for any of these values no determination strategy could be attempted, -// [[insufficient]] is returned. If the resultant datetime is invalid, +// [[insufficient]] is returned. If the resultant date is invalid, // [[invalid]] is returned. export fn realize( v: virtual, locs: time::chrono::locality... -) (datetime | insufficient | invalid) = { +) (date | insufficient | invalid) = { // determine .date if (v.date is i64) { void;