Skip to content

Commit 2165940

Browse files
camelidtshepang
authored andcommitted
Fix chrono deprecations
1 parent 09258ac commit 2165940

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

ci/date-check/src/main.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ struct Date {
1919

2020
impl Date {
2121
fn months_since(self, other: Date) -> Option<u32> {
22-
let self_chrono = Utc.ymd(self.year.try_into().unwrap(), self.month, 1);
23-
let other_chrono = Utc.ymd(other.year.try_into().unwrap(), other.month, 1);
22+
let self_chrono = Utc
23+
.with_ymd_and_hms(self.year.try_into().unwrap(), self.month, 1, 0, 0, 0)
24+
.unwrap();
25+
let other_chrono = Utc
26+
.with_ymd_and_hms(other.year.try_into().unwrap(), other.month, 1, 0, 0, 0)
27+
.unwrap();
2428
let duration_since = self_chrono.signed_duration_since(other_chrono);
2529
let months_since = duration_since.num_days() / 30;
2630
if months_since < 0 {
@@ -133,7 +137,7 @@ fn main() {
133137
let root_dir = args.nth(1).unwrap();
134138
let root_dir_path = Path::new(&root_dir);
135139
let glob_pat = format!("{}/**/*.md", root_dir);
136-
let today_chrono = Utc::today();
140+
let today_chrono = Utc::now().date_naive();
137141
let current_month = Date {
138142
year: today_chrono.year_ce().1,
139143
month: today_chrono.month(),

0 commit comments

Comments
 (0)