Repository navigation
Conversation
The four time scalars of HQL-0041 part 1, on jiff: constructors from ISO 8601 text and from parts in core, Eq and Ord for each, Add and Sub for Duration, and the time module's zones, parts, calendar arithmetic, truncation, strftime patterns and evaluation clock (--now, --zone). A declared time field reads its ISO text from JSON, YAML and CSV, and every format writes a time value as that text. SQL DATE, TIMESTAMP and TIMESTAMPTZ columns map to Date, DateTime and Instant. A declaration with no positional parameter takes Unit as its input, so now() and Date(year = ..., month = ..., day = ...) are calls. A spelling hint prefers prelude names and offers an imported-only name for a near miss alone.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements part 1 of HQL-0041, the
timemodule (issue 0064).What it adds
core:Date,DateTime,InstantandDuration, onjiff.Date("2026-10-24"), or from named parts,Date(year = 2026, month = 2, day = 28).EqandOrdfor each, so==,<,sort,max,Setandgroupcompare by time;AddandSubforDurationalone.timemodule (import time):year,weekday,iso_weekand the restadd_monthsclamps to the month's last daytruncatetoWeek,Month,QuarterandYear, anddates(start, end)fmtandparse_*with strftime patterns, andto_*conversions that givenonenow(),today()andlocal_zone(), read once per evaluation;--nowand--zonefix itString.DATE,TIMESTAMPandTIMESTAMPTZ, and SparkDATE,TIMESTAMP_NTZandTIMESTAMP, map toDate,DateTimeandInstant.Language changes to review
Unitas its input, and a call writes none.now()and the named-part constructors need this. Until nowfn now()was refused on purpose; the contract test now pins the new behaviour.pageswas answered withdates. Every hint that existed before is unchanged.Departures from HQL-0041 part 1
The spec now states each of these.
TimeUnit;Unitiscore's unit type.Utcvalue, because a module declares no values. A form without the zone reads in UTC; otherwise writeZone("UTC").Zoneis notOrderable.absoverDurationwaits until a second module can declareabsbesidemath.Open
Listed in issue 0064.
TIMESTAMPwith no offset; it is read as UTC.hql --versiondoes not yet name the zone database it carries.g.keyis refused insidegroupover a record type the program declares.Tests
tests/time.rs: 16 integration tests.src/time.rs.examples/time/: 12 corpus cases.cargo test(675 passed),cargo clippy --all-targets -- -D warningsandmkdocs build --strictare clean after mergingmain.