Skip to content

Commit 2a42a20

Browse files
authored
Merge pull request #1807 from ehuss/chrono-deprecated
Fix chrono deprecations.
2 parents 48f29f3 + 878770c commit 2a42a20

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/actions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl<'a> Action for Step<'a> {
182182
context.insert(name, issues);
183183
}
184184

185-
let date = chrono::Utc::today().format("%Y-%m-%d").to_string();
185+
let date = chrono::Utc::now().format("%Y-%m-%d").to_string();
186186
context.insert("CURRENT_DATE", &date);
187187

188188
Ok(TEMPLATES

src/handlers/docs_update.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ impl Job for DocsUpdateJob {
4747
// This is set to run the first week after a release, and the week just
4848
// before a release. That allows getting the latest changes in the next
4949
// release, accounting for possibly taking a few days for the PR to land.
50-
let today = chrono::Utc::today().naive_utc();
51-
let base = chrono::naive::NaiveDate::from_ymd(2015, 12, 10);
50+
let today = chrono::Utc::now().date_naive();
51+
let base = chrono::naive::NaiveDate::from_ymd_opt(2015, 12, 10).unwrap();
5252
let duration = today.signed_duration_since(base);
5353
let weeks = duration.num_weeks();
5454
if weeks % 2 != 0 {

src/handlers/types_planning_updates.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl Job for TypesPlanningMeetingThreadOpenJob {
2020

2121
async fn run(&self, ctx: &super::Context, _metadata: &serde_json::Value) -> anyhow::Result<()> {
2222
// On the last week of the month, we open a thread on zulip for the next Monday
23-
let today = chrono::Utc::now().date().naive_utc();
23+
let today = chrono::Utc::now().date_naive();
2424
let first_monday = today + chrono::Duration::days(7);
2525
// We actually schedule for every Monday, so first check if this is the last Monday of the month
2626
if first_monday.month() == today.month() {
@@ -43,10 +43,10 @@ impl Job for TypesPlanningMeetingThreadOpenJob {
4343
// Then, we want to schedule the next Thursday after this
4444
let mut thursday = today;
4545
while thursday.weekday().num_days_from_monday() != 3 {
46-
thursday = thursday.succ();
46+
thursday = thursday.succ_opt().unwrap();
4747
}
48-
let thursday_at_noon =
49-
Utc.from_utc_datetime(&thursday.and_time(NaiveTime::from_hms(12, 0, 0)));
48+
let noon = NaiveTime::from_hms_opt(12, 0, 0).unwrap();
49+
let thursday_at_noon = Utc.from_utc_datetime(&thursday.and_time(noon));
5050
let metadata = serde_json::value::to_value(PlanningMeetingUpdatesPingMetadata {
5151
date_string: meeting_date_string,
5252
})

0 commit comments

Comments
 (0)