Skip to content

Replace deprecated chrono with jiff - #8436

Open
joshuamegnauth54 wants to merge 1 commit into
RustPython:mainfrom
joshuamegnauth54:replace-deprecated-chrono
Open

Replace deprecated chrono with jiff#8436
joshuamegnauth54 wants to merge 1 commit into
RustPython:mainfrom
joshuamegnauth54:replace-deprecated-chrono

Conversation

@joshuamegnauth54

@joshuamegnauth54 joshuamegnauth54 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

See: chronotope/chrono#1768

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved date and time handling across supported platforms.
    • Added safer handling for invalid or unavailable build timestamps, with reliable fallback behavior.
    • Updated certificate validity dates and system time conversions for more consistent formatting.
  • Compatibility
    • Improved consistency of local-time, UTC, and calendar calculations across environments.
    • Enhanced platform-range validation for timestamp conversions to prevent invalid time values.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1631da45-f0f3-4fe1-85f1-48044b89b6f4

📥 Commits

Reviewing files that changed from the base of the PR and between 55e14ab and 92a0412.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • Cargo.toml
  • crates/stdlib/Cargo.toml
  • crates/stdlib/src/ssl/cert.rs
  • crates/vm/Cargo.toml
  • crates/vm/build.rs
  • crates/vm/src/stdlib/time.rs
🚧 Files skipped from review as they are similar to previous changes (6)
  • crates/stdlib/Cargo.toml
  • crates/vm/Cargo.toml
  • Cargo.toml
  • crates/vm/build.rs
  • crates/stdlib/src/ssl/cert.rs
  • crates/vm/src/stdlib/time.rs

📝 Walkthrough

Walkthrough

The PR replaces chrono with jiff across workspace dependencies, certificate validity formatting, VM build timestamps, and non-Unix/Windows runtime time handling.

Changes

Jiff time migration

Layer / File(s) Summary
Dependency wiring and certificate timestamps
Cargo.toml, crates/stdlib/Cargo.toml, crates/stdlib/src/ssl/cert.rs
The workspace and standard library replace chrono with jiff. Certificate validity timestamps use UTC jiff formatting.
VM build timestamp handling
crates/vm/Cargo.toml, crates/vm/build.rs
VM features and dependencies use jiff. Git timestamps use fallible parsing, system-timezone conversion, and strftime; invalid values fall back to the current time.
Runtime time conversion
crates/vm/src/stdlib/time.rs
Non-platform time conversion uses jiff::Timestamp, Zoned, and civil datetimes for gmtime, localtime, mktime, and struct_time handling.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested labels: z-ca-2026

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change from replacing the deprecated chrono dependency with jiff.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@joshuamegnauth54
joshuamegnauth54 marked this pull request as ready for review August 3, 2026 16:31
@joshuamegnauth54
joshuamegnauth54 force-pushed the replace-deprecated-chrono branch from 9e4ff33 to 55e14ab Compare August 3, 2026 16:31

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/vm/src/stdlib/time.rs`:
- Around line 429-432: Complete the Jiff migration in
OptionalArg::naive_or_local and the related non-Unix/non-Windows time
constructors: return Zoned instead of NaiveDateTime, pass tm.datetime() to
StructTimeData::new_inner, and update new_local to use the assigned tm value
rather than the undefined tz reference.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4709810b-04e7-4b17-a427-d7509f6b2732

📥 Commits

Reviewing files that changed from the base of the PR and between 51d7b50 and 55e14ab.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • Cargo.toml
  • crates/stdlib/Cargo.toml
  • crates/stdlib/src/ssl/cert.rs
  • crates/vm/Cargo.toml
  • crates/vm/build.rs
  • crates/vm/src/stdlib/time.rs

Comment thread crates/vm/src/stdlib/time.rs Outdated
Comment on lines +429 to +432
fn naive_or_local(self, vm: &VirtualMachine) -> PyResult<NaiveDateTime> {
Ok(match self {
Self::Present(t) => t.to_date_time(vm)?,
Self::Missing => chrono::offset::Local::now().naive_local(),
Self::Missing => Zoned::now().datetime(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

cargo fmt --check
cargo clippy --workspace --all-targets -- -D warnings
cargo check --manifest-path crates/vm/Cargo.toml --target wasm32-unknown-unknown

Repository: RustPython/RustPython

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Files matching time.rs:\n'
fd -a 'time\.rs$' . | sed 's#^\./##'

printf '\nRelevant lines 400-445 and 760-795:\n'
sed -n '400,445p;760,795p' crates/vm/src/stdlib/time.rs | nl -ba -v400

printf '\nImports in time.rs:\n'
sed -n '1,80p' crates/vm/src/stdlib/time.rs

Repository: RustPython/RustPython

Length of output: 405


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Relevant lines 400-445 and 760-795:\n'
sed -n '400,445p;760,795p' crates/vm/src/stdlib/time.rs > /tmp/time_section.txt
line=400
while IFS= read -r text || [ -n "$text" ]; do
  printf '%s:%s\n' "$line" "$text"
  line=$((line+1))
  [ "$line" -eq 446 ] && line=760
done < /tmp/time_section.txt

printf '\nImports in time.rs:\n'
sed -n '1,80p' crates/vm/src/stdlib/time.rs

printf '\nSearch for NaiveDateTime/jiff-related items in target file:\n'
rg 'NaiveDateTime|jiff|DateTime|Zoned|to_zoned|strftime|TimeZone|tz\.' crates/vm/src/stdlib/time.rs

Repository: RustPython/RustPython

Length of output: 8239


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Find chrono/NaiveDateTime definitions/usages in workspace:\n'
rg -n 'chrono|NaiveDateTime|chrono::' Cargo.toml Cargo.lock crates/vm/Cargo.toml crates/vm/src/stdlib/time.rs crates/vm/src/stdlib/ -g '*.rs' || true

printf '\nTarget cfg context around struct constructors:\n'
sed -n '`@680`,720p;740,790p' crates/vm/src/stdlib/time.rs | awk '{printf "%s:%s\n", NR+679, $0}'

Repository: RustPython/RustPython

Length of output: 1309


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Lines 620-680:\n'
sed -n '620,680p' crates/vm/src/stdlib/time.rs | awk '{printf "%s:%s\n", NR+619, $0}'

printf '\nLines 730-790:\n'
sed -n '730,790p' crates/vm/src/stdlib/time.rs | awk '{printf "%s:%s\n", NR+729, $0}'

printf '\nDependency declarations for chrono:\n'
sed -n '1,220p' crates/vm/Cargo.toml
rg -n 'chrono|jiff|dep:jiff|windows-local-time|xwin' Cargo.toml crates/vm/Cargo.toml Cargo.lock || true

Repository: RustPython/RustPython

Length of output: 8771


Complete the Jiff type migration for non-Unix/non-Windows time paths.

NaiveDateTime is no longer available after replacing chrono. Keep the non-Unix/non-Windows OptionalArg::naive_or_local() return type as Zoned, pass tm.datetime() into StructTimeData::new_inner, and fix new_local to use the assigned tm value instead of referencing undefined tz.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/vm/src/stdlib/time.rs` around lines 429 - 432, Complete the Jiff
migration in OptionalArg::naive_or_local and the related non-Unix/non-Windows
time constructors: return Zoned instead of NaiveDateTime, pass tm.datetime() to
StructTimeData::new_inner, and update new_local to use the assigned tm value
rather than the undefined tz reference.

Source: Coding guidelines

@joshuamegnauth54
joshuamegnauth54 force-pushed the replace-deprecated-chrono branch from 55e14ab to 92a0412 Compare August 3, 2026 17:04
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.

1 participant