Repository navigation
Print a Rust date the way it is read, so a year before 0 reads back - #1107
Merged
Merged
Conversation
jiff's Display writes a negative year with six digits (-000001), which the %Y-%m-%d that Date reads does not take, so since #1106 such a date no longer round-tripped through JSON as it did with chrono. Display now formats with the same %Y-%m-%d; for years 0 to 9999 the output is unchanged.
There was a problem hiding this comment.
🟢 Approved
There are no active review issues for the date-formatting change.
No open issues 🎉
What changed in this PR
Fixes Rust Date formatting after the jiff migration in #1106 so dates with negative years can round-trip through text and JSON.
Changes:
- Formats dates with
%Y-%m-%d, matching the parser. - Adds parsing and serde round-trip tests covering negative years, year zero, and calendar boundaries.
[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or rungh pr ready --undo.
Click "Ready for review" or rungh pr readyto reengage.
| File | Description |
|---|---|
rust/basecamp-sdk/src/types.rs |
Aligns date display with parsing and adds boundary round-trip tests. |
Review effort: Balanced
jeremy
added a commit
that referenced
this pull request
Nov 20, 2026
Prepares SDK v0.38.0 with `make bump VERSION=0.38.0`: version lines across Go, TypeScript, Ruby, Python, Kotlin, Swift and Rust, their lockfiles, and MIGRATING.md's Unreleased section promoted to v0.38.0. Release scope since v0.37.0: - #1106 Replace chrono with jiff in the Rust SDK (breaking, so a minor before 1.0) - #1107 Print a Rust date the way it is read, so a year before 0 reads back
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.
Follow-up to #1106. jiff's
civil::DateDisplaywrites a year before 0 with six digits (-000001-01-01), butDateparses with%Y-%m-%d, which reads at most four. SoDate::new(-1, 1, 1)printed, and serialized, as something it couldn't read back. chrono round-tripped it. Copilot found the same thing on the matching hey-sdk change (basecamp/hey-sdk#311).Displaynow formats with the same%Y-%m-%dit parses with. For years 0 to 9999 the output is byte-identical to before (checked across 59,997 dates from -9999 to 9999, all of which round-trip). The newevery_date_reads_back_what_it_printstest round-trips the calendar's ends, -1 and 0 through bothDate::parseand serde.Neither API sends such dates, so this only matters to a caller building one by hand. It is a patch-level fix to an unreleased change.
Summary by cubic
Fixes date display so a year before 0 prints as something
Datecan read back. jiff'sDisplaywrites a year before 0 with six digits (-000001), which%Y-%m-%dparsing doesn't read, so such a date no longer round-tripped through printing or JSON as it did with chrono.Displaynow formats with the same%Y-%m-%dused for parsing; years 0-9999 print byte-identically. A new test round-trips the calendar's ends, years before 0 included, through bothDate::parseand serde. Neither API sends such dates, so this only matters when building one by hand.Written for commit 522cb5f. Summary will update on new commits.