Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 21 additions & 101 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ bitflags = "2.11.0"
bitflagset = "0.0.3"
bstr = { version = "1", default-features = false, features = ["unicode"] }
bzip2 = "0.6"
chrono = { version = "0.4.44", default-features = false, features = ["clock", "std"] }
console_error_panic_hook = "0.1"
constant_time_eq = "0.5"
cranelift = "0.132.0"
Expand Down Expand Up @@ -231,6 +230,7 @@ insta = "1.47"
itertools = { version = "0.15.0", default-features = false, features = ["use_alloc"] }
itoa = "1"
is-macro = "0.3.7"
jiff = "0.2"
js-sys = "0.3"
junction = "2.0.0"
lexical-parse-float = "1.0.6"
Expand Down
2 changes: 1 addition & 1 deletion crates/stdlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@
bzip2 = { workspace = true }

# tkinter
jiff = { workspace = true }
tk-sys = { workspace = true, optional = true }
tcl-sys = { workspace = true, optional = true }

Check warning on line 91 in crates/stdlib/Cargo.toml

View workflow job for this annotation

GitHub Actions / cargo shear

shear/unused_optional_dependency

unused optional dependency `tcl-sys`
widestring = { workspace = true, optional = true }
chrono.workspace = true

# uuid
[target.'cfg(not(any(target_os = "ios", target_os = "android", target_os = "windows", target_arch = "wasm32", target_os = "redox")))'.dependencies]
Expand All @@ -108,8 +108,8 @@
rustls = { workspace = true, default-features = false, features = ["std", "tls12"], optional = true }
rustls-native-certs = { workspace = true, optional = true }
rustls-pemfile = { workspace = true, optional = true }
rustls-platform-verifier = { workspace = true, optional = true }

Check warning on line 111 in crates/stdlib/Cargo.toml

View workflow job for this annotation

GitHub Actions / cargo shear

shear/unused_optional_dependency

unused optional dependency `rustls-platform-verifier`
x509-cert = { workspace = true, features = ["pem", "builder"], optional = true }

Check warning on line 112 in crates/stdlib/Cargo.toml

View workflow job for this annotation

GitHub Actions / cargo shear

shear/unused_optional_dependency

unused optional dependency `x509-cert`
x509-parser = { workspace = true, optional = true }
der = { workspace = true, optional = true }
pem-rfc7468 = { workspace = true, features = ["alloc"], optional = true }
Expand Down
14 changes: 7 additions & 7 deletions crates/stdlib/src/ssl/cert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//! - Loading certificates from files, directories, and bytes

use alloc::sync::Arc;
use chrono::{DateTime, Utc};
use jiff::{Timestamp, Zoned, tz::TimeZone};
use parking_lot::RwLock as ParkingRwLock;
use rustls::{
DigitallySignedStruct, RootCertStore, SignatureScheme,
Expand Down Expand Up @@ -201,10 +201,10 @@ fn format_ip_address(ip: &[u8]) -> String {
/// Formats certificate validity dates in the format:
/// "Mon DD HH:MM:SS YYYY GMT"
fn format_asn1_time(time: &x509_parser::time::ASN1Time) -> String {
let timestamp = time.timestamp();
DateTime::<Utc>::from_timestamp(timestamp, 0)
.expect("ASN1Time must be valid timestamp")
.format("%b %e %H:%M:%S %Y GMT")
let timestamp =
Timestamp::from_second(time.timestamp()).expect("ASN1Time must be valid timestamp");
Zoned::new(timestamp, TimeZone::UTC)
.strftime("%b %e %H:%M:%S %Y GMT")
.to_string()
}

Expand Down Expand Up @@ -341,7 +341,7 @@ pub(super) fn cert_to_dict(
let serial = format_serial_number(&cert.serial);
dict.set_item("serialNumber", vm.ctx.new_str(serial).into(), vm)?;

// Validity dates - format with GMT using chrono
// Validity dates - format with GMT using jiff
dict.set_item(
"notBefore",
vm.ctx
Expand Down Expand Up @@ -414,7 +414,7 @@ pub(super) fn cert_der_to_dict_helper(
// CPython ordering: issuer, notAfter, notBefore, serialNumber, subject, version
dict.set_item("issuer", name_to_tuple(cert.issuer())?, vm)?;

// Validity - format with GMT using chrono
// Validity - format with GMT using jiff
dict.set_item(
"notAfter",
vm.ctx
Expand Down
6 changes: 3 additions & 3 deletions crates/vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ast = ["ruff_python_ast", "ruff_text_size"]
codegen = ["rustpython-codegen", "ast"]
parser = ["ast"]
serde = ["dep:serde"]
wasmbind = ["rustpython-common/wasm_js", "chrono/wasmbind", "wasm-bindgen"]
wasmbind = ["rustpython-common/wasm_js", "jiff/js", "wasm-bindgen"]

[dependencies]
rustpython-compiler = { workspace = true, optional = true }
Expand All @@ -48,14 +48,14 @@ ascii = { workspace = true }
bitflags = { workspace = true }
bstr = { workspace = true }
crossbeam-utils = { workspace = true }
chrono = { workspace = true }
constant_time_eq = { workspace = true }
flame = { workspace = true, optional = true }
hex = { workspace = true }
indexmap = { workspace = true }
itertools = { workspace = true }
itoa = { workspace = true }
is-macro = { workspace = true }
jiff = { workspace = true }
libc = { workspace = true }
log = { workspace = true }
malachite-bigint = { workspace = true }
Expand Down Expand Up @@ -91,9 +91,9 @@ widestring = { workspace = true }
wasm-bindgen = { workspace = true, optional = true }

[build-dependencies]
chrono = { workspace = true }
glob = { workspace = true }
itertools = { workspace = true }
jiff = { workspace = true }

[lints]
workspace = true
22 changes: 12 additions & 10 deletions crates/vm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
reason = "build scripts cannot use rustpython-host_env"
)]

use chrono::{Local, prelude::DateTime};
use core::time::Duration;
use itertools::Itertools;
use jiff::{Timestamp, Zoned, tz::TimeZone};
use std::{
env,
io::{self, prelude::*},
Expand Down Expand Up @@ -123,24 +122,27 @@ fn git_identifier() -> String {
}
}

fn get_git_timestamp_datetime() -> DateTime<Local> {
let timestamp = git_timestamp().parse::<u64>().unwrap_or_default();
let datetime = UNIX_EPOCH + Duration::from_secs(timestamp);
datetime.into()
fn get_git_timestamp_raw() -> Option<Timestamp> {
let git_timestamp = git_timestamp().parse::<i64>().ok()?;
Timestamp::from_second(git_timestamp).ok()
}

fn get_git_timestamp_datetime() -> Zoned {
get_git_timestamp_raw().map_or_else(Zoned::now, |timestamp| {
Zoned::new(timestamp, TimeZone::system())
})
}

#[must_use]
fn get_git_date() -> String {
let datetime = get_git_timestamp_datetime();

datetime.format("%b %e %Y").to_string()
datetime.strftime("%b %e %Y").to_string()
}

#[must_use]
fn get_git_time() -> String {
let datetime = get_git_timestamp_datetime();

datetime.format("%H:%M:%S").to_string()
datetime.strftime("%H:%M:%S").to_string()
}

fn rustc_version() -> String {
Expand Down
Loading
Loading