Repository navigation
A month or a year stored at its own precision can be truncated, so "2024-03" truncated to a month is 2024-03-01 instead of no value - #1407
Open
rudycelekli wants to merge 2 commits into
Conversation
WaylandYang
requested changes
Oct 24, 2026
WaylandYang
left a comment
Contributor
There was a problem hiding this comment.
Thanks, the bug is real: normalize_attr_value stores 2024-03 and 2024, and date_trunc gives no value for them today. Two things: please update ADR 0036's list of accepted date inputs (it still names only an ISO calendar date or an RFC 3339 timestamp), and require four ASCII digits for the year form so +202 or -123 aren't read as years.
…024-03" truncated to a month is 2024-03-01 instead of no value Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
…036 lists the month and year forms it accepts Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
rudycelekli
force-pushed
the
fix/coarse-date-trunc
branch
from
November 5, 2026 03:15
cc2da48 to
b074125
Compare
Contributor
Author
|
ADR 0036 now lists the month (2024-03) and four-digit year (2024) inputs and says a value cannot be truncated finer than it states; the bare-year form now requires four ASCII digits, with "+202" and "-123" added as no-value cases in calendar_truncation_uses_utc_and_rejects_ambiguous_or_invalid_dates. Rebased on dev. |
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.
Why
Date attributes keep the precision that was written: a month is
2024-03, a year is2024.date_trunconly parsed a fullYYYY-MM-DDor an offset timestamp, so truncating either of those values produced no result. A rule that floors a month-precision date to its month, or a year-precision date to its year, dropped the fact.What changes
YYYY-MMandYYYYparse as that month and that year. Truncation still cannot invent a finer part: a month truncated to a day, or a year truncated to a month, stays absent. Offset timestamps are unchanged, and a timestamp without an offset is still rejected.How it was checked
In
calendar_truncation_uses_utc_and_rejects_ambiguous_or_invalid_dates:2024-03is2024-03-012024-03is2024-01-012024is2024-01-01On the original function the month case fails with
left: None. With the change,cargo test -p utopia-reason --libpasses (108).cargo fmt -p utopia-reasonandcargo clippy -p utopia-reason --all-targets -- -D warningspass.Before review
git commit -s)cargo fmt,cargo clippyandcargo testpass for the touched crate