Skip to content

Commit c35028a

Browse files
authored
refactor: drop time crate in favor of std::time::SystemTime (#2059)
* refactor: drop time crate in favor of std::time::SystemTime * use as_secs_f64 * don't panic, but return None
1 parent e3d8be4 commit c35028a

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

neqo-common/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ env_logger = { version = "0.10", default-features = false }
2222
hex = { version = "0.4", default-features = false, features = ["alloc"], optional = true }
2323
log = { workspace = true }
2424
qlog = { workspace = true }
25-
time = { version = "0.3", default-features = false, features = ["formatting"] }
2625

2726
[dev-dependencies]
2827
test-fixture = { path = "../test-fixture" }

neqo-common/src/qlog.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::{
1111
io::BufWriter,
1212
path::PathBuf,
1313
rc::Rc,
14+
time::SystemTime,
1415
};
1516

1617
use qlog::{
@@ -172,13 +173,10 @@ pub fn new_trace(role: Role) -> qlog::TraceSeq {
172173
common_fields: Some(CommonFields {
173174
group_id: None,
174175
protocol_type: None,
175-
reference_time: {
176-
// It is better to allow this than deal with a conversion from i64 to f64.
177-
// We can't do the obvious two-step conversion with f64::from(i32::try_from(...)),
178-
// because that overflows earlier than is ideal. This should be fine for a while.
179-
#[allow(clippy::cast_precision_loss)]
180-
Some((time::OffsetDateTime::now_utc().unix_timestamp() * 1000) as f64)
181-
},
176+
reference_time: SystemTime::now()
177+
.duration_since(SystemTime::UNIX_EPOCH)
178+
.map(|d| d.as_secs_f64() * 1_000.0)
179+
.ok(),
182180
time_format: Some("relative".to_string()),
183181
}),
184182
}

0 commit comments

Comments
 (0)