[PATCH] fix: use OffsetDateTime::now_utc() as now() has been deprecated
Export this patch
Signed-off-by: Ken Swenson <flat@esoteric.moe>
---
src/comic.rs | 8 ++++----
src/syndicate.rs | 4 ++--
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/comic.rs b/src/comic.rs
index 138a4e0..70c55ad 100644
--- a/src/comic.rs
+++ b/src/comic.rs
@@ -121,13 +121,13 @@ impl ComicEmbed {
}
pub fn today(self) -> Self {
- let now = OffsetDateTime::now().to_offset(INDIANA).date();
+ let now = OffsetDateTime::now_utc().to_offset(INDIANA).date();
self.date(now)
}
pub fn yesterday(self) -> Self {
let day = time::Duration::day();
- let yesterday = OffsetDateTime::now().to_offset(INDIANA).date() - day;
+ let yesterday = OffsetDateTime::now_utc().to_offset(INDIANA).date() - day;
self.date(yesterday)
}
@@ -142,7 +142,7 @@ impl ComicEmbed {
}
pub fn random(self) -> Self {
- let now = OffsetDateTime::now().to_offset(INDIANA).date();
+ let now = OffsetDateTime::now_utc().to_offset(INDIANA).date();
let dur = now - GARFIELD_EPOCH;
let days_since = dur.whole_days();
@@ -187,7 +187,7 @@ impl ComicEmbed {
}
fn garfield_url(date: Date) -> Option<String> {
- let now = OffsetDateTime::now().to_offset(INDIANA).date();
+ let now = OffsetDateTime::now_utc().to_offset(INDIANA).date();
if date > GARFIELD_EPOCH && date <= now {
Some(format!("https://d1ejxu6vysztl5.cloudfront.net/comics/garfield/{}/{}-{:02}-{:02}.gif?format=png",
date.year(),
diff --git a/src/syndicate.rs b/src/syndicate.rs
index 0225617..bd0af52 100644
--- a/src/syndicate.rs
+++ b/src/syndicate.rs
@@ -16,13 +16,13 @@ const MORNING: time::Time = time::time!(11:00);
const DAY: time::Duration = time::Duration::day();
pub fn next_time() -> tokio::time::Instant {
- let now = OffsetDateTime::now();
+ let now = OffsetDateTime::now_utc();
let date = now.date();
let mut next = PrimitiveDateTime::new(date, MORNING).assume_utc();
if next < now {
next += DAY;
}
- let wait: std::time::Duration = (next - OffsetDateTime::now()).try_into().unwrap();
+ let wait: std::time::Duration = (next - OffsetDateTime::now_utc()).try_into().unwrap();
let next_instant = std::time::Instant::now() + wait;
tokio::time::Instant::from_std(next_instant)
}
--
2.26.2