Skip to content

deps: migrate from chrono to jiff - #871

Open
wtcpython wants to merge 1 commit into
uutils:mainfrom
wtcpython:jiff-migration
Open

wtcpython wants to merge 1 commit into
uutils:mainfrom
wtcpython:jiff-migration

Conversation

@wtcpython

Copy link
Copy Markdown
Contributor

Replace chrono with jiff across find and locate.

@codecov

codecov Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.62887% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.24%. Comparing base (8f17c13) to head (ff99276).

Files with missing lines Patch % Lines
src/locate/mod.rs 63.33% 8 Missing and 3 partials ⚠️
src/find/matchers/printf.rs 95.83% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #871      +/-   ##
==========================================
- Coverage   92.27%   92.24%   -0.04%     
==========================================
  Files          35       35              
  Lines        7576     7595      +19     
  Branches      393      397       +4     
==========================================
+ Hits         6991     7006      +15     
- Misses        443      445       +2     
- Partials      142      144       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 20 untouched benchmarks


Comparing wtcpython:jiff-migration (ff99276) with main (8f17c13)

Open in CodSpeed

@wtcpython
wtcpython marked this pull request as ready for review September 26, 2026 01:06
Copilot AI lite review requested due to automatic review settings September 26, 2026 01:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment thread src/locate/mod.rs Outdated
writeln!(out, "Database was last modified at {}", time)?;
if let Ok(ts) = jiff::Timestamp::try_from(time) {
let time = ts.to_zoned(jiff::tz::TimeZone::system());
writeln!(out, "Database was last modified at {}", time)?;

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.

this changes the output: chrono printed 2025-01-15 09:30:21.123 +01:00, jiff's Display prints 2025-01-15T09:30:21.123+01:00[Europe/Paris].
is that intended? if not, please use an explicit strftime.

Comment thread src/find/matchers/mod.rs Outdated
format!("{} {}", now.strftime("%b"), now.strftime("%d")),
|m| m.as_str().to_string(),
);
let mut month_chars = month_day.chars();

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.

why is this needed? jiff's %b parsing is already case-insensitive, so this could be removed, no?

Comment thread src/find/matchers/printf.rs Outdated
.to_string()
zoned.strftime(CTIME_FORMAT).to_string()
}
Self::Strftime(format) => zoned.strftime(format).to_string(),

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.

strftime(..).to_string() panics if formatting fails.
apply already returns a Result, could you please use jiff::fmt::strtime::format and ? here?

Comment thread src/find/matchers/printf.rs Outdated
Err(format!("Invalid time specifier: %{first}{c}").into())
}
Some(_item) => Ok(TimeFormat::Strftime(format)),
let dummy = jiff::Zoned::now();

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.

do we need Zoned::now() for every specifier? a fixed timestamp would do.

Comment thread src/find/matchers/time.rs Outdated
.start_of_day()
.unwrap();
let ts = midnight.timestamp();
UNIX_EPOCH + Duration::from_secs(ts.as_second() as u64)

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.

SystemTime::from(midnight.timestamp()) would avoid the as u64 cast, no?

Comment thread src/locate/mod.rs Outdated

#[test]
#[cfg(target_pointer_width = "64")]
fn db_too_old_ignores_max_age_beyond_chrono_range() {

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.

the name still says chrono, please rename it (or drop it if it no longer tests anything specific)

Comment thread src/find/matchers/mod.rs Outdated
if let Ok(datetime) = jiff::civil::DateTime::strptime("%Y-%m-%d %H:%M:%S", date_str) {
return Some(
datetime
.to_zoned(jiff::tz::TimeZone::UTC)

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.

.to_zoned(TimeZone::UTC).ok()?.timestamp().as_millisecond() appears 3 times, could be dedup, no?
TimeZone::UTC.to_timestamp(dt) is shorter too.

Comment thread src/find/matchers/printf.rs Outdated

impl TimeFormat {
fn apply(&self, time: SystemTime) -> Result<Cow<'static, str>, Box<dyn Error>> {
let zoned = jiff::Timestamp::try_from(time)?.to_zoned(jiff::tz::TimeZone::system());

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.

this is now computed for SinceEpoch too, where it isn't used, and it can make %A@ fail for times outside jiff's range.
could you please move it into the branches that need it?

Copilot AI review requested due to automatic review settings September 26, 2026 11:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment thread src/locate/mod.rs Outdated
#[cfg(target_pointer_width = "64")]
fn db_too_old_ignores_max_age_beyond_chrono_range() {
assert!(!is_db_too_old(TimeDelta::days(1), 1_000_000_000_000));
fn db_too_old_ignores_max_age_beyond_range() {

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.

with checked_mul, 1e12 days no longer overflows, so this test is now the same as db_too_old_compares_ordinary_ages.
could you please drop it, or use a value that really overflows?

Comment thread src/find/matchers/ls.rs Outdated
let system_time = metadata.modified().unwrap();
let now_utc: DateTime<chrono::Utc> = system_time.into();
now_utc.format("%b %e %H:%M")
let ts = jiff::Timestamp::try_from(system_time).unwrap();

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.

could we avoid the unwrap() here? a file with an mtime outside jiff's range would make -ls panic

Comment thread src/find/matchers/mod.rs Outdated
let year = match captures.get(2) {
Some(m) => m.as_str().parse().ok()?,
None => now.year(),
None => now.year() as i32,

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.

i32::from(now.year()) instead of as, no?

Comment thread src/find/matchers/mod.rs Outdated
let now_but_zero_hour_min_sec = Utc::now()
.date_naive()
.and_hms_opt(0, 0, 0)
let now_but_zero_hour_min_sec = jiff::Timestamp::now()

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.

TimeZone::UTC.to_timestamp(..) would be shorter here too, like in the function

Copilot AI review requested due to automatic review settings September 27, 2026 00:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings September 28, 2026 00:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings September 29, 2026 06:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI lite review requested due to automatic review settings October 2, 2026 12:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

Commit ff99276 has test result changes:

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 315 / PASSED: 272 / FAILED: 37 / SKIPPED: 6
  Reference: TOTAL: 316 / PASSED: 273 / FAILED: 37 / SKIPPED: 6

Changes from main branch:
  TOTAL: -1
  PASSED: -1
  FAILED: +0

No result in this run (2) - hung, crashed, or renamed:
  ? gnu/executable (was PASS)
  ? posix/exec_plus_semicolon (was PASS)

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