Skip to content

Commit 7d04cca

Browse files
committed
chrono: Address deprecation warnings
1 parent e75967c commit 7d04cca

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/posts.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,7 @@ impl Post {
158158
}
159159

160160
fn build_post_time(year: i32, month: u32, day: u32, seconds: u32) -> String {
161-
chrono::DateTime::<chrono::Utc>::from_utc(
162-
chrono::NaiveDate::from_ymd(year, month, day).and_hms(0, 0, seconds),
163-
chrono::Utc,
164-
)
165-
.to_rfc3339()
161+
let date = chrono::NaiveDate::from_ymd_opt(year, month, day).unwrap();
162+
let date_time = date.and_hms_opt(0, 0, seconds).unwrap();
163+
chrono::DateTime::<chrono::Utc>::from_naive_utc_and_offset(date_time, chrono::Utc).to_rfc3339()
166164
}

0 commit comments

Comments
 (0)