diff --git a/src/actions.rs b/src/actions.rs index a9509171..ecf9c518 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -182,7 +182,7 @@ impl<'a> Action for Step<'a> { context.insert(name, issues); } - let date = chrono::Utc::today().format("%Y-%m-%d").to_string(); + let date = chrono::Utc::now().format("%Y-%m-%d").to_string(); context.insert("CURRENT_DATE", &date); Ok(TEMPLATES diff --git a/src/handlers/docs_update.rs b/src/handlers/docs_update.rs index d6a9168f..c134c880 100644 --- a/src/handlers/docs_update.rs +++ b/src/handlers/docs_update.rs @@ -47,8 +47,8 @@ impl Job for DocsUpdateJob { // This is set to run the first week after a release, and the week just // before a release. That allows getting the latest changes in the next // release, accounting for possibly taking a few days for the PR to land. - let today = chrono::Utc::today().naive_utc(); - let base = chrono::naive::NaiveDate::from_ymd(2015, 12, 10); + let today = chrono::Utc::now().date_naive(); + let base = chrono::naive::NaiveDate::from_ymd_opt(2015, 12, 10).unwrap(); let duration = today.signed_duration_since(base); let weeks = duration.num_weeks(); if weeks % 2 != 0 { diff --git a/src/handlers/types_planning_updates.rs b/src/handlers/types_planning_updates.rs index a6c9c0c4..54bf26f9 100644 --- a/src/handlers/types_planning_updates.rs +++ b/src/handlers/types_planning_updates.rs @@ -20,7 +20,7 @@ impl Job for TypesPlanningMeetingThreadOpenJob { async fn run(&self, ctx: &super::Context, _metadata: &serde_json::Value) -> anyhow::Result<()> { // On the last week of the month, we open a thread on zulip for the next Monday - let today = chrono::Utc::now().date().naive_utc(); + let today = chrono::Utc::now().date_naive(); let first_monday = today + chrono::Duration::days(7); // We actually schedule for every Monday, so first check if this is the last Monday of the month if first_monday.month() == today.month() { @@ -43,10 +43,10 @@ impl Job for TypesPlanningMeetingThreadOpenJob { // Then, we want to schedule the next Thursday after this let mut thursday = today; while thursday.weekday().num_days_from_monday() != 3 { - thursday = thursday.succ(); + thursday = thursday.succ_opt().unwrap(); } - let thursday_at_noon = - Utc.from_utc_datetime(&thursday.and_time(NaiveTime::from_hms(12, 0, 0))); + let noon = NaiveTime::from_hms_opt(12, 0, 0).unwrap(); + let thursday_at_noon = Utc.from_utc_datetime(&thursday.and_time(noon)); let metadata = serde_json::value::to_value(PlanningMeetingUpdatesPingMetadata { date_string: meeting_date_string, })