meridian 12 now works on timezone command

This commit is contained in:
jellywx 2020-12-28 21:58:58 +00:00
parent 2db405866f
commit 55c7740cef
4 changed files with 20 additions and 5 deletions

2
Cargo.lock generated
View File

@ -1316,7 +1316,7 @@ dependencies = [
[[package]]
name = "reminder_rs"
version = "1.3.3"
version = "1.3.4"
dependencies = [
"Inflector",
"async-trait",

View File

@ -1,6 +1,6 @@
[package]
name = "reminder_rs"
version = "1.3.3"
version = "1.3.4"
authors = ["jellywx <judesouthworth@pm.me>"]
edition = "2018"

View File

@ -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::<Tz>().unwrap())
.format("%H:%M")
.format(user_data.meridian().fmt_str_short())
.to_string()
),
true,

View File

@ -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 {