Skip to content

Commit 07e55e9

Browse files
committed
Replace deprecated items in chrono v0.4.23
1 parent b6ff9dc commit 07e55e9

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

spdlog/src/formatter/local_time_cacher.rs

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -360,45 +360,52 @@ mod tests {
360360

361361
#[test]
362362
fn leap_second() {
363-
let (date_2015, date_2022) = (Utc.ymd(2015, 6, 30), Utc.ymd(2022, 6, 30));
363+
let (date_2015, date_2022) = (
364+
NaiveDate::from_ymd_opt(2015, 6, 30).unwrap(),
365+
NaiveDate::from_ymd_opt(2022, 6, 30).unwrap(),
366+
);
364367

365-
enum UtcKind {
368+
enum Kind {
366369
NonLeap,
367370
Leap,
368371
}
369372

370373
let datetimes = [
371374
(
372-
UtcKind::NonLeap,
373-
date_2015.and_hms_nano(23, 59, 59, 100_000_000),
375+
Kind::NonLeap,
376+
date_2015.and_hms_nano_opt(23, 59, 59, 100_000_000).unwrap(),
374377
),
375378
(
376-
UtcKind::Leap,
377-
date_2015.and_hms_nano(23, 59, 59, 1_000_000_000),
379+
Kind::Leap,
380+
date_2015
381+
.and_hms_nano_opt(23, 59, 59, 1_000_000_000)
382+
.unwrap(),
378383
),
379384
(
380-
UtcKind::Leap,
381-
date_2015.and_hms_nano(23, 59, 59, 1_100_000_000),
385+
Kind::Leap,
386+
date_2015
387+
.and_hms_nano_opt(23, 59, 59, 1_100_000_000)
388+
.unwrap(),
382389
),
383-
(UtcKind::NonLeap, date_2022.and_hms(23, 59, 59)),
390+
(Kind::NonLeap, date_2022.and_hms_opt(23, 59, 59).unwrap()),
384391
(
385-
UtcKind::NonLeap,
386-
date_2022.and_hms_nano(23, 59, 59, 100_000_000),
392+
Kind::NonLeap,
393+
date_2022.and_hms_nano_opt(23, 59, 59, 100_000_000).unwrap(),
387394
),
388395
];
389396

390397
let mut cacher = LocalTimeCacher::new();
391398

392399
for datetime in datetimes {
393400
let leap = match datetime.0 {
394-
UtcKind::NonLeap => false,
395-
UtcKind::Leap => true,
401+
Kind::NonLeap => false,
402+
Kind::Leap => true,
396403
};
397-
let utc = datetime.1;
404+
let datetime = datetime.1;
398405

399-
println!(" => checking '{utc}'");
406+
println!(" => checking '{datetime}'");
400407

401-
let result = cacher.get_inner(utc);
408+
let result = cacher.get_inner(datetime.and_local_timezone(Utc).unwrap());
402409
assert_eq!(result.cached.is_leap_second, leap);
403410
assert_eq!(result.second(), if !leap { 59 } else { 60 });
404411
}

spdlog/src/sink/rotating_file_sink.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ mod tests {
11011101

11021102
#[test]
11031103
fn calc_file_path() {
1104-
let system_time = Local.ymd(2012, 3, 4).and_hms(5, 6, 7).into();
1104+
let system_time = Local.with_ymd_and_hms(2012, 3, 4, 5, 6, 7).unwrap().into();
11051105

11061106
let calc_daily = |base_path| {
11071107
RotatorTimePoint::calc_file_path(

0 commit comments

Comments
 (0)