From 55c7740cef641b50783be8fd1abed9729fc90873 Mon Sep 17 00:00:00 2001 From: jellywx Date: Mon, 28 Dec 2020 21:58:58 +0000 Subject: [PATCH] meridian 12 now works on timezone command --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/commands/moderation_cmds.rs | 13 ++++++++++--- src/models.rs | 8 ++++++++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8cc3fc3..06d6f00 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1316,7 +1316,7 @@ dependencies = [ [[package]] name = "reminder_rs" -version = "1.3.3" +version = "1.3.4" dependencies = [ "Inflector", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 085df17..592e276 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "reminder_rs" -version = "1.3.3" +version = "1.3.4" authors = ["jellywx "] edition = "2018" diff --git a/src/commands/moderation_cmds.rs b/src/commands/moderation_cmds.rs index eb31d24..2e28980 100644 --- a/src/commands/moderation_cmds.rs +++ b/src/commands/moderation_cmds.rs @@ -107,7 +107,11 @@ async fn timezone(ctx: &Context, msg: &Message, args: String) { let content = lm .get(&user_data.language, "timezone/set_p") .replacen("{timezone}", &user_data.timezone, 1) - .replacen("{time}", &now.format("%H:%M").to_string(), 1); + .replacen( + "{time}", + &now.format(user_data.meridian().fmt_str_short()).to_string(), + 1, + ); let _ = msg.channel_id @@ -138,7 +142,10 @@ async fn timezone(ctx: &Context, msg: &Message, args: String) { tz_s, format!( "🕗 `{}`", - Utc::now().with_timezone(tz).format("%H:%M").to_string() + Utc::now() + .with_timezone(tz) + .format(user_data.meridian().fmt_str_short()) + .to_string() ), true, ) @@ -179,7 +186,7 @@ async fn timezone(ctx: &Context, msg: &Message, args: String) { "🕗 `{}`", Utc::now() .with_timezone(&t.timezone.parse::().unwrap()) - .format("%H:%M") + .format(user_data.meridian().fmt_str_short()) .to_string() ), true, diff --git a/src/models.rs b/src/models.rs index 675ab56..a13d862 100644 --- a/src/models.rs +++ b/src/models.rs @@ -193,6 +193,14 @@ impl MeridianType { "%Y-%m-%d %H:%M:%S" } } + + pub fn fmt_str_short(&self) -> &str { + if self.0 { + "%I:%M %p" + } else { + "%H:%M" + } + } } impl UserData {