switch to jiff from chrono (#6205)

This PR migrates uv's use of `chrono` to `jiff`.

I did most of this work a while back as one of my tests to ensure Jiff
could actually be used in a real world project. I decided to revive
this because I noticed that `reqwest-retry` dropped its Chrono
dependency,
which is I believe the only other thing requiring Chrono in uv.
(Although, we use a fork of `reqwest-middleware` at present, and that
hasn't been updated to latest upstream yet. I wasn't quite sure of the
process we have for that.)

In course of doing this, I actually made two changes to uv:

First is that the lock file now writes an RFC 3339 timestamp for
`exclude-newer`. Previously, we were using Chrono's `Display`
implementation for this which is a non-standard but "human readable"
format. I think the right thing to do here is an RFC 3339 timestamp.

Second is that, in addition to an RFC 3339 timestamp, `--exclude-newer`
used to accept a "UTC date." But this PR changes it to a "local date."
That is, a date in the user's system configured time zone. I think
this makes more sense than a UTC date, but one alternative is to drop
support for a date and just rely on an RFC 3339 timestamp. The main
motivation here is that automatically assuming UTC is often somewhat
confusing, since just writing an unqualified date like `2024-08-19` is
often assumed to be interpreted relative to the writer's "local" time.
This commit is contained in:
Andrew Gallant 2024-08-19 10:36:00 -07:00 committed by Zanie Blue
parent c8f27a3978
commit 33480d61eb
38 changed files with 285 additions and 213 deletions

View file

@ -20,9 +20,9 @@ uv-fs = { workspace = true, features = ["serde"] }
uv-git = { workspace = true }
uv-normalize = { workspace = true }
chrono = { workspace = true, features = ["serde"] }
indexmap = { workspace = true, features = ["serde"] }
itertools = { workspace = true }
jiff = { workspace = true, features = ["serde"] }
mailparse = { workspace = true }
regex = { workspace = true }
rkyv = { workspace = true }

View file

@ -1,6 +1,6 @@
use std::str::FromStr;
use chrono::{DateTime, Utc};
use jiff::Timestamp;
use serde::{Deserialize, Deserializer, Serialize};
use pep440_rs::{VersionSpecifiers, VersionSpecifiersParseError};
@ -51,7 +51,7 @@ pub struct File {
#[serde(default, deserialize_with = "deserialize_version_specifiers_lenient")]
pub requires_python: Option<Result<VersionSpecifiers, VersionSpecifiersParseError>>,
pub size: Option<u64>,
pub upload_time: Option<DateTime<Utc>>,
pub upload_time: Option<Timestamp>,
pub url: String,
pub yanked: Option<Yanked>,
}