Repository navigation
Conversation
|
@bgentry This really sucks, but chrono's never going to get less deprecated, so the best time to switch is still probably now. Jiff does seem a little better designed, and there was some nice simplification opportunities. For example, previously River had to do some pretty gnarly stuff to get specific RFC3339 formatting: pub(crate) fn format_rfc3339_nano(timestamp: DateTime<Utc>) -> String {
let mut formatted = timestamp.to_rfc3339_opts(SecondsFormat::Secs, true);
let nanos = timestamp.nanosecond() % 1_000_000_000;
if nanos > 0 {
let fraction = format!("{nanos:09}");
formatted.insert(formatted.len() - 1, '.');
formatted.insert_str(formatted.len() - 1, fraction.trim_end_matches('0'));
}
formatted
}Now it's just Codex had some ideas about potentially putting in a date/time indirection layer to River, but that's definitely got some tradeoffs. I think the BurntSushi crates (which jiff is) have a pretty good maintenance track record, so it might be worth being a bit more optimistic about this one. |
| let utc = naive.checked_sub_signed(chrono::Duration::seconds(offset))?; | ||
| let corrected = offset_at(utc); | ||
| fn resolve_local(zone: &TimeZone, naive: DateTime) -> Option<Zoned> { | ||
| let local = naive.to_zoned(TimeZone::UTC).ok()?.timestamp(); |
There was a problem hiding this comment.
🤖 Idiom nit: building a UTC Zoned just to get its timestamp can be TimeZone::UTC.to_timestamp(naive).ok()? (or Offset::UTC.to_timestamp(naive)). parse_rfc3339 in attempt_error.rs does the same round trip through to_zoned and could use Offset::to_timestamp too.
This one predates the PR: in the block below, if corrected != offset { offset = corrected; } is equivalent to offset = corrected;.
There was a problem hiding this comment.
🤖 Left these unchanged. Direct UTC-to-timestamp conversion is a valid simplification, but the current round trips are correct. The conditional offset assignment is also confirmed to predate this PR, so it remains outside the regression fixes.
| let today = date | ||
| .to_datetime(time) | ||
| .to_zoned(jiff::tz::TimeZone::UTC) | ||
| .expect("valid UTC date") |
There was a problem hiding this comment.
🤖 Nit: the .to_zoned(UTC).expect("valid UTC date").timestamp() chain appears twice. TimeZone::UTC.to_timestamp(datetime) (or a small local closure) would remove the duplicate and the second expect.
There was a problem hiding this comment.
🤖 Left this small duplication unchanged. The direct conversion would be a stylistic simplification, but no behavior regression was identified in these two daily-schedule conversions. The separate interval-overflow issue is fixed in e66b027.
| mod support; | ||
|
|
||
| use chrono::{DateTime, Duration, TimeZone, Utc}; | ||
| use jiff::{SignedDuration as Duration, Timestamp}; |
There was a problem hiding this comment.
🤖 Nit: aliasing SignedDuration as Duration (here and in tests/sqlite_storage.rs) is confusing next to std::time::Duration, which River's public API uses for delays. Using SignedDuration by name would avoid that.
There was a problem hiding this comment.
🤖 Left these aliases unchanged. The alias itself is new, but both test files already used Duration for Chrono's signed duration type. Keeping that local naming convention avoids unrelated test churn; neither file imports std::time::Duration under the same name.
|
🤖 Coverage gaps worth closing, beyond the inline notes:
|
|
🤖 PR hygiene: the title has the
Separately, the CHANGELOG entry is one long "Breaking" bullet; splitting it into a few bullets and stating the new range explicitly ("timestamps outside years -9999 to 9999 are rejected") would make it easier to scan. |
It was called to my attention last week that it turns out that what's been traditionally the main date/time library in Rust, chrono, is actually soft deprecated [1]. The chrono maintainer recommends jiff [2] as a replacement. I figure that since River Rust is still quite new and River Pro for Rust is still unreleased, it's the best time ever to make this jump. Although annoying, jiff does seem to be very thoughtfully designed, with heavy inspiration from Temporal in JavaScript. [1] chronotope/chrono#1768 [2] https://crates.io/crates/jiff
Handle SQLite timestamp boundaries without panicking, preserve stored negative-year timestamps, and retain column names in unexpected-NULL errors. Saturate retry, retention, and reindex arithmetic at Jiff's timestamp bounds. Reject newly accepted Temporal syntax in cancellation timestamps while preserving Chrono's existing parsing leniency. Make jiff-sqlx optional and Postgres-only. Add boundary and decode-error coverage, clarify go_time's behavior and the breaking changelog entries, and move the Chrono migration guide out of the README into a separate published documentation page. Validation: - make test/rust with Postgres and SQLite: 577 passed, 1 ignored - make lint/rust - make doc/rust
|
🤖 Follow-up on the coverage suggestions, addressed in e66b027:
Validation passed: |
|
🤖 Addressed the PR hygiene feedback. Both commits now start with The migration guide has also moved to a separate document, linked from the README and included in generated documentation. |
|
Thx! |
🤖 It was called to my attention last week that it turns out that what's
been traditionally the main date/time library in Rust, chrono, is
actually soft deprecated [1]. The chrono maintainer recommends jiff [2]
as a replacement.
I figure that since River Rust is still quite new and River Pro for Rust
is still unreleased, it's the best time ever to make this jump. Although
annoying, jiff does seem to be very thoughtfully designed, with heavy
inspiration from Temporal in JavaScript.
[1] chronotope/chrono#1768
[2] https://crates.io/crates/jiff
Compatibility changes:
jiff::Timestamp, re-exported throughriverqueue::jiff.Timestamp::MINthroughTimestamp::MAX. Timestamps outside years -9999 to 9999 are rejected, including stored database values outside that range.chrono-tzfeature is renamed totzdb.CronTimeZoneremainsClonebut no longer implementsCopy; its fixed and named variants usejiff::tz::Offsetandjiff::tz::TimeZone.CronSchedule::next_aftertakes&jiff::Zonedand returnsOption<jiff::Zoned>, preserving the reference time zone.PostgresReindexSchedule::DailyUtctakesjiff::civil::Time.Persisted database formats and canonical timestamp JSON remain unchanged; existing databases require no schema migration. The migration guide includes examples for replacing Chrono types.