From 3499e349b02815cee61f8064951b32e2ac6c3bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Wed, 19 Oct 2022 12:34:27 +0200 Subject: [PATCH] Add weekday to dates --- src/bot.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/bot.rs b/src/bot.rs index 2507e7b..4612a84 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -1,4 +1,5 @@ use anyhow::{Error, Result}; +use chrono::Datelike; use chrono::Utc; use chrono_tz::Europe; use diesel::Connection; @@ -145,10 +146,20 @@ pub async fn fetch_and_announce_appointment( .with_timezone(&Europe::Berlin) .format("%d.%m.%Y %H:%M"); + let weekday = match appointment.start.weekday() { + chrono::Weekday::Mon => "Montag", + chrono::Weekday::Tue => "Dienstag", + chrono::Weekday::Wed => "Mittwoch", + chrono::Weekday::Thu => "Donnerstag", + chrono::Weekday::Fri => "Freitag", + chrono::Weekday::Sat => "Samstag", + chrono::Weekday::Sun => "Sonntag", + }; + let announcement = bot .send_message( ChatId(chat_info.id), - format!("Nächster Termin: {}", date_str), + format!("Nächster Termin: {}, {}", weekday, date_str), ) .await?;