Update dependencies

This commit is contained in:
2023-01-26 12:57:21 +01:00
parent 509824a926
commit e12f371340
4 changed files with 291 additions and 163 deletions

View File

@@ -53,7 +53,11 @@ pub async fn fetch_next_appointment<U: IntoUrl>(url: U) -> Result<Option<Appoint
let end = *ends.get(uid).unwrap();
// Move the end time to the day of the current series element
let end = start.date().and_time(end.naive_local().time()).unwrap();
let end = start
.date_naive()
.and_time(end.naive_local().time())
.and_local_timezone(start.timezone())
.unwrap();
return Ok(Some(Appointment { start, end }));
}

View File

@@ -33,7 +33,7 @@ impl From<DbChat> for ChatInfo<Utc> {
// Convert timestamps to datetimes
.map(|timestamps| {
timestamps
.map(|timestamp| NaiveDateTime::from_timestamp(timestamp, 0))
.map(|timestamp| NaiveDateTime::from_timestamp_opt(timestamp, 0).unwrap())
.map(|date_time| DateTime::<Utc>::from_utc(date_time, Utc))
})
// Join datetimes into Appointment
@@ -41,7 +41,7 @@ impl From<DbChat> for ChatInfo<Utc> {
let last_reminder = db_chat
.last_reminder
.map(|timestamp| NaiveDateTime::from_timestamp(timestamp, 0))
.map(|timestamp| NaiveDateTime::from_timestamp_opt(timestamp, 0).unwrap())
.map(|date_time| DateTime::<Utc>::from_utc(date_time, Utc));
let locale = db_chat.locale.unwrap_or("de".into());

View File

@@ -105,7 +105,7 @@ async fn main() {
};
let sleep_duration = next_appointment
.map(|timestamp| NaiveDateTime::from_timestamp(timestamp, 0))
.map(|timestamp| NaiveDateTime::from_timestamp_opt(timestamp, 0).unwrap())
.map(|naive_date_time| DateTime::<Utc>::from_utc(naive_date_time, Utc))
.map(|date_time| date_time - now)
.map(|duration| duration.to_std().unwrap())
@@ -160,7 +160,11 @@ async fn check_task(bot: &Throttle<Bot>, reminder_time: NaiveTime, db: &Database
text: t!("messages.starting_now", locale = &chat_info.locale),
});
} else {
let reminder_date_time = now.date().and_time(reminder_time).unwrap();
let reminder_date_time = now
.date_naive()
.and_time(reminder_time)
.and_local_timezone(now.timezone())
.unwrap();
if now >= reminder_date_time {
reminder = Some(Reminder {
time: reminder_date_time,