Skip to content

calendar: Replace chrono with jiff - #4015

Merged
madcodelife merged 2 commits into
longbridge:mainfrom
ketansingrole:replace-chrono-with-jiff
Nov 17, 2026
Merged

madcodelife merged 2 commits into
longbridge:mainfrom
ketansingrole:replace-chrono-with-jiff

Conversation

@ketansingrole

@ketansingrole ketansingrole commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes: no issue; sent directly as a PR, as CONTRIBUTING prefers.

Description

Replace chrono with jiff 1.0 in the Calendar, DatePicker and TimeField, and remove chrono from every manifest in the workspace.

RUSTSEC-2026-0543 marks chrono as unmaintained, so cargo deny check advisories fails for every application that depends on gpui-kit. The advisory and chrono's maintainer (chronotope/chrono#1768) recommend jiff as the replacement.

Scope:

  • gpui-base: this touches the Base layer because the date and time types are part of its public API (Date, Matcher, CalendarState, TimeFieldState); the component layer only re-exports them. calendar.rs and time_field.rs use jiff::civil::{Date, Time, Weekday}. The month grid is built with Date::series; behaviour is unchanged (the existing tests pass as they were, apart from constructing dates with civil::date).
  • gpui-component: time/date_picker.rs and time/calendar.rs follow. time/utils.rs is deleted: it is not declared in time/mod.rs, so it was never compiled, and it only referenced chrono.
  • gpui-shell: the calendar binding parses "YYYY-MM-DD" with civil::Date::strptime, and the bundle writer reads the local time from jiff::ZonedDateTime::now().
  • Story, examples, the gpui-kit integration test and the website docs (en and zh-CN) are updated to jiff.
  • On wasm32, gpui-base enables jiff's js feature so CalendarState::new can still read today's date in the browser, as chrono's default wasmbind feature did.
  • Format strings are unchanged: jiff's strftime accepts the same %Y, %m, %d, %H, %M, %S, %I and %p directives used here.

AI-generated: the port, the docs changes and this description were written with AI (Claude Code).

After this PR, chrono remains in Cargo.lock only through gpui-pre-scheduler (upstream Zed), which is outside this repository.

Public API

gpui-base (re-exported from gpui_component::calendar and gpui_component::time_field):

  • Date::Single(Option<jiff::civil::Date>), Date::Range(Option<jiff::civil::Date>, Option<jiff::civil::Date>): the calendar value.
  • impl From<jiff::civil::Date> for Date, impl From<(jiff::civil::Date, jiff::civil::Date)> for Date: build a single date or a range.
  • Date::start(&self) -> Option<jiff::civil::Date>, Date::end(&self) -> Option<jiff::civil::Date>: read the range ends.
  • Date::is_active(&self, &jiff::civil::Date) -> bool, Date::is_in_range(&self, &jiff::civil::Date) -> bool: hit tests for a day cell.
  • Date::format(&self, &str) -> Option<SharedString>: now formats with jiff's strftime.
  • Matcher::Custom(Box<dyn Fn(&jiff::civil::Date) -> bool + Send + Sync>), Matcher::custom, Matcher::interval(Option<jiff::civil::Date>, Option<jiff::civil::Date>), Matcher::range(..), Matcher::matched(&self, &jiff::civil::Date) -> bool, impl<F: Fn(&jiff::civil::Date) -> bool> From<F> for Matcher: disable dates.
  • CalendarState::select_date(&mut self, jiff::civil::Date) -> bool, CalendarState::activate_date(&mut self, jiff::civil::Date, &mut Context<Self>) -> bool: select a day.
  • CalendarState::days(&self) -> Vec<Vec<jiff::civil::Date>>, CalendarState::month_days(&self) -> Vec<Vec<Vec<jiff::civil::Date>>>, CalendarState::today(&self) -> jiff::civil::Date: the visible grid and today.
  • Calendar::first_day_of_week(self, jiff::civil::Weekday) -> Self: the first column of the grid.
  • TimePrecision::truncate(self, jiff::civil::Time) -> jiff::civil::Time: drop components finer than the precision.
  • TimeFieldEvent::Change(jiff::civil::Time), TimeFieldState::time(&self) -> jiff::civil::Time, TimeFieldState::set_time(&mut self, jiff::civil::Time, &mut Window, &mut Context<Self>): the edited time.

gpui-component:

  • date_picker::DateTime::Single(Option<jiff::civil::DateTime>), DateTime::Range(Option<jiff::civil::DateTime>, Option<jiff::civil::DateTime>), DateTime::start, DateTime::end, impl From<jiff::civil::DateTime> for DateTime, impl From<(jiff::civil::DateTime, jiff::civil::DateTime)> for DateTime: the date-time value.
  • DateRangePresetValue::Single(jiff::civil::Date), DateRangePresetValue::Range(jiff::civil::Date, jiff::civil::Date), DateRangePreset::single(label, jiff::civil::Date), DateRangePreset::range(label, jiff::civil::Date, jiff::civil::Date): presets.
  • DatePickerState::default_time(self, jiff::civil::Time) -> Self, DatePickerState::first_day_of_week(self, jiff::civil::Weekday) -> Self: configuration.
  • calendar::Calendar::first_day_of_week(self, jiff::civil::Weekday) -> Self: the first column of the grid.

Breaking Changes

Every item above took a chrono type and now takes the matching jiff type, so applications using the Calendar, DatePicker or TimeField replace chrono with jiff = "1.0" in their own manifest:

chrono jiff
NaiveDate jiff::civil::Date
NaiveTime jiff::civil::Time
NaiveDateTime jiff::civil::DateTime
Weekday::Sun, Weekday::Mon, … Weekday::Sunday, Weekday::Monday, …
Local::now().naive_local().date() jiff::ZonedDateTime::now().date()
- use chrono::{Days, Local, NaiveTime, Weekday};
+ use jiff::{ToSpan as _, ZonedDateTime, civil::{self, Weekday}};

- let today = Local::now().naive_local().date();
+ let today = ZonedDateTime::now().date();
- picker.set_date((today, today.checked_add_days(Days::new(7)).unwrap()), window, cx);
+ picker.set_date((today, today + 7.days()), window, cx);

  DatePickerState::new(window, cx)
-     .default_time(NaiveTime::from_hms_opt(9, 0, 0).unwrap())
+     .default_time(civil::time(9, 0, 0, 0))
-     .first_day_of_week(Weekday::Mon)
+     .first_day_of_week(Weekday::Monday)

Year, month and day accessors on jiff dates return i16/i8 instead of chrono's i32/u32. CalendarState::current_year, current_month and set_year_range keep their existing types.

How to Test

Run on macOS ARM64.

With Rust 1.100.0:

  • cargo clippy --workspace --exclude gpui-shell --exclude webview --locked -- --deny warnings: clean.
  • cargo clippy -p gpui-shell --all-targets --locked -- --deny warnings: clean.
  • cargo machete: no unused dependencies.

With Rust 1.98.1:

  • cargo test -p gpui-base --lib -- calendar time_field, cargo test -p gpui-component --features test-support --lib -- time::, cargo test -p gpui-shell --lib bundle
  • cargo test -p gpui-kit --features test-support --test integration date_picker
  • cargo check -p gpui-base -p gpui-component -p gpui-kit -p gpui-component-story --tests --features gpui-component-story/test-support
  • cargo check -p gpui-kit --features gpui-fast --target wasm32-unknown-unknown on nightly-2026-10-31

Stories (cargo run, macOS): Calendar, DatePicker and TimeField render as before. Today's date and the local time come from jiff; the month grids are right across the November → December 2026 → January 2027 rollover; the weekend matcher greys Saturday and Sunday; the "Yesterday" preset selects the previous day and reports 2026-11-16; the 12-hour TimeField shows AM.

Checklist

  • I have read the CONTRIBUTING document and followed the guidelines.
  • Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate. The port was written with Claude Code.
  • Passed cargo run for story tests related to the changes.
  • Tested macOS, Windows and Linux platforms performance (if the change is platform-specific)

🤖 Generated with Claude Code

RUSTSEC-2026-0543 marks chrono unmaintained, so `cargo deny` fails for
applications that depend on gpui-kit. The advisory and chrono's maintainer
recommend jiff.

The Calendar, DatePicker and TimeField now take `jiff::civil::{Date, Time,
DateTime, Weekday}` instead of chrono's naive types. This is a breaking change
to their public API.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@huacnlee

Copy link
Copy Markdown
Member

💡 Needs the maintainer's call: clean port, but it swaps a public dependency (breaking API for every Calendar/DatePicker/TimeField user).

Reviewed at 7059b1f.

  • Motivation is real: RUSTSEC-2026-0543 flags chrono as unmaintained, and jiff is the replacement chrono's maintainer recommends.
  • Scope looks focused: 29 files, +368/−627; the unused time/utils.rs removal is correct (not declared in time/mod.rs). No chrono left in any workspace manifest.
  • Public API: every date/time type in gpui-base and gpui-component moves from chrono to jiff::civil::*, so this is a breaking change and should go into the next minor (breaking) release, not a patch.
  • Ran locally (Linux): cargo test -p gpui-base --lib -- calendar time_field → 20 passed.

The remaining decision is whether gpui-kit wants jiff as its public date type (vs. e.g. waiting / keeping chrono until upstream drops it).

🤖 Noop (reviewer) · AI agent acting for @huacnlee

@huacnlee

Copy link
Copy Markdown
Member

✅ Accepted: the maintainer agreed to move from chrono to jiff.

Since this changes the public types of the calendar, date picker and time input APIs, it will ship in the next minor (breaking) release, not a patch. Please keep the branch up to date with main; we will merge it once CI is green.

Reviewed at 7059b1f.

🤖 Noop (reviewer) · AI agent acting for @huacnlee

@madcodelife
madcodelife merged commit 69dab1a into longbridge:main Nov 17, 2026
19 checks passed
@madcodelife

Copy link
Copy Markdown
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants