Expand description
Cypher temporal-value construction, evaluated at lowering time.
The openCypher TCK constructs temporals from literal arguments —
date('2015-W30-2'), date({year: 2015, month: 7, day: 21}) — and renders
the result as a quoted canonical ISO string ('2015-07-21'). Because the
argument is a constant, we can parse and canonicalise it during lowering
(graphforge-rel) and emit a plain Utf8 literal, without a runtime UDF. Only the
non-literal forms (rare in the corpus) fall back to DataFusion’s
to_date/to_char.
This module currently covers date(<string>). The map form
(date({year, month, day}) / ISO-week construction) and the time-bearing
types (localtime/time/localdatetime/datetime) are follow-ups (#599).
Structs§
- Date
Overrides - Component overrides for
date-from-value projection (Temporal3). A field leftNoneis taken from the base date. The active construction mode is selected by which override is present (week ▸ ordinal ▸ quarter ▸ calendar). - Duration
Value - A Cypher duration: months and days are kept distinct (a month is not a fixed
number of days), with everything finer than a day carried in
nanos(integer nanoseconds — exact even for very large sub-day spans, unlike anf64seconds count whose mantissa drops sub-second precision past ~1e15ns). A typed Cypher duration (ADR 0009 / #1011): signedmonths/dayskept distinct (a month is not a fixed number of days), and the sub-day time split into wholesecondsplusnanos-of-second. Splitting seconds from nanos lets a billion-yearduration.inSeconds(~6.3e16 s) fiti64, where a single total-nanos field would overflow (~6.3e25 ns);months: i64likewise holds the ~24e9-month spansduration.betweencan produce.nanosis in(-1e9, 1e9)and shares the sign ofseconds(truncating split). - Local
Time Overrides - Component overrides for
localtimeprojection (localtime({time: base, …})): a field leftNonekeeps the base’s value; the sub-second fields, if any are present, jointly replace the base fraction.
Enums§
- Between
Mode - Which
duration.between-family function: the full split, or a single-unit total. - Temporal
Field - A temporal map-constructor field value, extracted from a literal map
argument (
date({year: 1984, …})) at lowering time. Variable references and other non-constant values can’t be extracted and make construction bail to the runtime path. (#599)
Functions§
- date_
component - A
datecomponent value (openCypherTemporal5). ISO-8601 semantics forweek/weekYear/weekDay;weekDayis 1 (Monday) … 7 (Sunday).Nonefor an unknown accessor name. - date_
from_ map - Build a
date(i64 days) from a literal map — the typed-value path (ADR 0009).Noneif the fields don’t form a valid date. (#1011) - date_
plus_ duration date + duration(#920): only date-precision components apply — add the signed months then days. The duration’s sub-day time is ignored (a date has no time-of-day; openCypher does not carry it into days). Returns the date (i64 days), range-complete viacrate::calendar(#1011).- date_
to_ epoch_ days - i64 days since the Unix epoch (1970-01-01) for a chrono
NaiveDate. No clamping — the full range round-trips (#1011). - datetime_
plus_ duration localdatetime/datetime + duration(#920): add the signed months, then days, then the sub-day time (carrying whole-day overflow into the date). Returns the resulting(date, nanos_of_day).- datetime_
value_ from_ map - Build a
datetimefrom a literal field map (datetime({…, timezone})). - datetime_
value_ from_ str - Parse a
datetime(<string>)— offset form (…T…+01:00) or named-zone form (…T…[Europe/London], offset resolved at that instant). (ADR 0009) - duration_
between - Compute
duration.between/inMonths/inDays/inSecondsfromatobas a typedDurationValue(#920/#1011). Both operands dated → a calendar-aware month/day/time split (shifted to UTC instants only when both carry a zone offset); either operand time-only → just the time-of-day difference (no month/day span), offset-adjusted only when both are zoned. - duration_
component - A duration component accessor (
d.years,d.monthsOfQuarter,d.secondsOfMinute,d.nanosecondsOfSecond, …) over a typed duration. The*Of*forms give the component within the next-larger unit; the plain forms give the total in that unit (truncated toward zero).Nonefor an unknown name. (#920) - duration_
value_ from_ map - Build a
duration({…})DurationValuefrom a literal map. (#920/#1011) - duration_
value_ from_ str - Parse
duration(<string>)to a typedDurationValue. (#920/#1011) - epoch_
component - A
datetimeepoch component (Temporal5):epochSeconds/epochMillis— the UTC instant of(date_days, nanos_of_day, offset_seconds).Nonefor an unknown accessor name. (#920) - epoch_
days_ to_ date - The chrono
NaiveDatefor an i64 days-since-epoch value — the in-range bridge for the date functions that keep chrono internals (projection, truncation, accessors, map construction). ReturnsNonefor a date outside chrono’s ±262k-year range; such extreme dates only occur on the parse→duration.betweenpath, which usescrate::calendardirectly. (#1011) - format_
date - Canonical openCypher rendering of a date (i64 days):
YYYY-MM-DD, signed for the expanded-year range (#1011). Delegates tocrate::calendar. - is_
date_ accessor - Whether
nameis adatecomponent accessor (d.year,d.weekDay, …). - is_
duration_ accessor - Whether
nameis a duration component accessor (seeduration_component). - is_
epoch_ accessor - Whether
nameis adatetimeepoch accessor (d.epochSeconds/d.epochMillis). (#920) - is_
time_ accessor - Whether
nameis a time-of-day component accessor (d.hour,d.nanosecond, …) — valid onlocaltime/time/localdatetime/datetime. (#920) - is_
zone_ int_ accessor - Whether
nameis a zone INT accessor (d.offsetMinutes/d.offsetSeconds) — valid ontime/datetime. (#920) - is_
zone_ str_ accessor - Whether
nameis a zone STRING accessor (d.timezone/d.offset) — valid ontime/datetime. (#920) - localdatetime_
parts_ from_ map - Build a
localdatetime(date + nanoseconds-of-day) from a literal field map. (ADR 0009) - localdatetime_
parts_ from_ str - Parse a
localdatetime(<string>)(YYYY-…T HH:MM…) to (date-days, nanoseconds- of-day) — a date and time with NO offset (an offset is rejected, matchingrender_local_date_time). - localtime_
nanos_ from_ map - Build a
localtime(nanoseconds-of-day) from a literal field map. (ADR 0009) - localtime_
nanos_ from_ str - Parse a strict
localtime(<string>)to nanoseconds-of-day — a time of day with NO offset (an offset is rejected, matchingrender_local_time). - localtime_
plus_ duration localtime/time + duration(#920): only the sub-day time applies (months/days are irrelevant to a time-of-day), wrapping mod 24h.- parse_
date_ or_ datetime_ prefix - The date component (i64 days) of a runtime temporal value for projection — a
date is taken directly; a string is parsed as a date or the date part of a
datetime (
2015-07-21T…). (#920/#1011) - parse_
date_ string - Parse a Cypher ISO-8601 date string into a
NaiveDate. - parse_
offset_ seconds - Parse a UTC offset designator (
Z,±HH,±HH:MM, …) to signed seconds — the public entry point for atime/datetimetimezoneoverride. (ADR 0009) - project_
date - Project a base date (i64 days) through component overrides (openCypher
date({date: base, …})select-semantics): takebase, replace the named components, keep the rest. Range-complete viacalendar(#920/#1011). - project_
datetime - Project a
datetime(Temporal3[8]-[11]): apply the source’s zone to the local(date, nanos)after component overrides. With a newtimezone: a numeric offset or named zone SHIFTS the instant when the source already had an offset (time/datetime), else ATTACHES (interpreting the local time as being in that zone). Without one, the source offset/zone (or UTC) is kept. (ADR 0009) - project_
localtime - Project a base localtime through component overrides (select-semantics:
replace the named components, keep the rest).
Nonefor an out-of-range component. (ADR 0009) - project_
time - Apply a
timeprojection’s zone semantics. With a new offset: if the base already had one (time/datetime), the wall-clock time SHIFTS to preserve the instant; otherwise (localtime/localdatetime) the offset is simply ATTACHED. Without a new offset, the base offset (or UTC) is kept. (ADR 0009) - render_
date - Canonical openCypher rendering of
date(<string>), orNoneif the string is not a recognised ISO date form. - render_
date_ time - Canonical openCypher rendering of
datetime(<string>)— a date and time with a zone — orNone. Handles both the offset form (…T21:40:32+01:00) and the named-zone form (…T21:40:32[Europe/London], whose offset is resolved from the IANA tz database at that instant, including historical LMT offsets like+00:53:28). - render_
datetime_ value - Canonical openCypher rendering of a
datetime:YYYY-MM-DDTHH:MM…±HH:MM(Zfor UTC), plus a trailing[Zone]for a named zone. (ADR 0009) - render_
duration - Canonical openCypher rendering of
duration(<string>), orNoneif the string is not a recognised ISO-8601 duration. Handles the designator form (P14DT16H12M, with decimal components likeP0.75M/P2.5Wspilling into smaller units) and the alternative date-time form (P2012-02-02T14:37:21.545). - render_
duration_ value - Canonical openCypher rendering of a typed
DurationValue(reuses the same designator formatter as the string path; the integerseconds/nanosare preserved exactly, so a very large span renders without f64 precision loss). (#920) - render_
from_ epoch datetime.fromepoch(seconds, nanoseconds)— a UTC datetime from a Unix epoch offset.- render_
from_ epoch_ millis datetime.fromepochmillis(milliseconds)— a UTC datetime from Unix epoch milliseconds.- render_
local_ date_ time - Canonical openCypher rendering of
localdatetime(<string>)— a date and time with no zone — orNone. - render_
local_ time - Canonical openCypher rendering of
localtime(<string>)— a time of day with no zone — orNone. - render_
localdatetime - Canonical openCypher rendering of a
localdatetime(date-days + nanoseconds- of-day):YYYY-MM-DDTHH:MM[:SS[.fff…]], time precision derived from the value. - render_
localtime_ nanos - Canonical openCypher rendering of an Arrow
Time64(Nanosecond)localtime (HH:MM/HH:MM:SS/HH:MM:SS.fff…, trailing-zero subseconds trimmed). - render_
temporal_ map - Canonical rendering of a temporal constructor called with a literal map
argument (
date({year: 1984, month: 10, day: 11})), orNoneif the fields don’t form a valid value forname. (#599) - render_
time - Canonical openCypher rendering of
time(<string>)— a time of day with a zone offset — orNone. The offset is required. - render_
time_ value - Canonical openCypher rendering of a
timevalue (nanoseconds-of-day + offset-seconds): time-of-day + offset (Zfor UTC). (ADR 0009) - scale_
duration duration * factor/duration / factor(#920 Temporal8 [7]). Scales each component byfactor, then normalises with the openCypher “approximate” rule: a fractional month overflows into days (× the Gregorian average month length,MONTH_SECS / DAY_SECS = 30.436875days), a fractional day overflows into the sub-day time, each level truncated toward zero.factoris the multiplier (* n) or1/nis applied by the caller for division — here we take the already-resolved factor asnumwithdivideselecting1/numcomponent-wise to preserve precision.- time_
component - A time-of-day component value (openCypher
Temporal5) from a nanoseconds-of-day.millisecond/microsecond/nanosecondare the CUMULATIVE sub-second value at that resolution (645 / 645876 / 645876123), not the digits of a single place.Nonefor an unknown accessor name. (#920) - time_
of_ day_ nanos_ any - Extract the time-of-day (nanoseconds-of-day) from ANY temporal string —
localtime,time(offset dropped), orlocaldatetime/datetime(date prefix and any zone dropped) — for projecting a localtime out of another value (localtime({time: other})). (ADR 0009) - time_
of_ day_ with_ offset - Extract a time-of-day and (optional) offset from ANY temporal string for
timeprojection:localtime/localdatetime→ offsetNone(the new zone is attached);time/datetime→Some(offset)(a new zone shifts the instant). Drops a named-zone suffix and a date prefix. (ADR 0009) - time_
offset_ zone - Extract
(nanoseconds-of-day, optional offset-seconds, optional zone label)from ANY temporal string —localtime/localdatetime→ offset/zoneNone;time→Some(offset), no zone;datetime→ offset + optional zone. Used when projecting adatetimefrom another value. (ADR 0009) - time_
value_ from_ map - Build a
time(nanoseconds-of-day, offset-seconds) from a literal field map (time({hour, …, timezone}); default zone is UTC). (ADR 0009) - time_
value_ from_ str - Parse a
time(<string>)to (nanoseconds-of-day, offset-seconds). The offset is REQUIRED (atimecarries a zone). (ADR 0009) - truncate_
date - Truncate a date to the start of a unit (openCypher
date.truncate(unit, …)):millennium/century/decaderound the year down;year/month/quarter→ the first day of that period;weekYear→ the Monday of ISO week 1;week→ the Monday of the date’s week;day→ the date itself. The optional override map is applied afterwards viaproject_date.Nonefor an unknown unit. (#920) - truncate_
time_ nanos - Truncate a time-of-day (nanoseconds since midnight) to the start of a unit
(openCypher
localtime.truncate(unit, …)and the time component of the other*.truncate):hour/minute/second/millisecond/microsecondfloor to that boundary; any unit coarser than a time-of-day (dayand up) → midnight (0).Nonefor an unknown unit. (#920) - zone_
int_ component - A zone INT component (
Temporal5):offsetMinutes/offsetSecondsfrom a UTC offset in seconds.Nonefor an unknown accessor name. (#920) - zone_
str_ component - A zone STRING component (
Temporal5):offset(the±HH:MMdesignator) ortimezone(the named IANA zone if present, else the offset designator).Nonefor an unknown accessor name. (#920)
Type Aliases§
- Between
Operand - A reduced temporal operand for
duration_between: an optional date (Nonefor a time-onlylocaltime/time), a time-of-day in nanoseconds, an optional zone offset in seconds (Nonefor an unzoned value), and an optional named IANA zone (Someonly for adatetimeconstructed with a zone name — needed to re-resolve the offset across a DST transition). (#920/#1007)