Skip to content

Commit

Permalink
Merge pull request #1807 from ehuss/chrono-deprecated
Browse files Browse the repository at this point in the history
Fix chrono deprecations.
  • Loading branch information
jackh726 authored May 29, 2024
2 parents 48f29f3 + 878770c commit 2a42a20
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/docs_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions src/handlers/types_planning_updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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,
})
Expand Down

0 comments on commit 2a42a20

Please sign in to comment.