revert some usages of discord builtin timestamp formatting
This commit is contained in:
parent
40630c0014
commit
98aed91d21
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -210,7 +210,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "command_attr"
|
name = "command_attr"
|
||||||
version = "0.3.7"
|
version = "0.3.7"
|
||||||
source = "git+https://github.com/serenity-rs/serenity?branch=next#4d431726f4eb2f29a040b83fb4a18a459427c1b2"
|
source = "git+https://github.com/serenity-rs/serenity?branch=next#8b327ddb3057f6f672c303d1e5d1806b8f024f71"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -1481,7 +1481,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "serenity"
|
name = "serenity"
|
||||||
version = "0.10.8"
|
version = "0.10.8"
|
||||||
source = "git+https://github.com/serenity-rs/serenity?branch=next#4d431726f4eb2f29a040b83fb4a18a459427c1b2"
|
source = "git+https://github.com/serenity-rs/serenity?branch=next#8b327ddb3057f6f672c303d1e5d1806b8f024f71"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"async-tungstenite",
|
"async-tungstenite",
|
||||||
|
@ -214,9 +214,9 @@ async fn nudge(ctx: &Context, msg: &Message, args: String) {
|
|||||||
#[command("look")]
|
#[command("look")]
|
||||||
#[permission_level(Managed)]
|
#[permission_level(Managed)]
|
||||||
async fn look(ctx: &Context, msg: &Message, args: String) {
|
async fn look(ctx: &Context, msg: &Message, args: String) {
|
||||||
let (pool, lm) = get_ctx_data(&ctx).await;
|
let (pool, _lm) = get_ctx_data(&ctx).await;
|
||||||
|
|
||||||
let language = UserData::language_of(&msg.author, &pool).await;
|
let timezone = UserData::timezone_of(&msg.author, &pool).await;
|
||||||
|
|
||||||
let flags = LookFlags::from_string(&args);
|
let flags = LookFlags::from_string(&args);
|
||||||
|
|
||||||
@ -237,14 +237,12 @@ async fn look(ctx: &Context, msg: &Message, args: String) {
|
|||||||
if reminders.is_empty() {
|
if reminders.is_empty() {
|
||||||
let _ = msg
|
let _ = msg
|
||||||
.channel_id
|
.channel_id
|
||||||
.say(&ctx, lm.get(&language, "look/no_reminders"))
|
.say(&ctx, "No reminders on specified channel")
|
||||||
.await;
|
.await;
|
||||||
} else {
|
} else {
|
||||||
let inter = lm.get(&language, "look/inter");
|
|
||||||
|
|
||||||
let display = reminders
|
let display = reminders
|
||||||
.iter()
|
.iter()
|
||||||
.map(|reminder| reminder.display(&flags, inter));
|
.map(|reminder| reminder.display(&flags, &timezone));
|
||||||
|
|
||||||
let _ = msg.channel_id.say_lines(&ctx, display).await;
|
let _ = msg.channel_id.say_lines(&ctx, display).await;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,8 @@ use serenity::{
|
|||||||
model::id::{ChannelId, GuildId, UserId},
|
model::id::{ChannelId, GuildId, UserId},
|
||||||
};
|
};
|
||||||
|
|
||||||
use chrono::NaiveDateTime;
|
use chrono::{NaiveDateTime, TimeZone};
|
||||||
|
use chrono_tz::Tz;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
models::reminder::{
|
models::reminder::{
|
||||||
@ -314,18 +315,20 @@ WHERE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn display(&self, flags: &LookFlags, inter: &str) -> String {
|
pub fn display(&self, flags: &LookFlags, timezone: &Tz) -> String {
|
||||||
let time_display = match flags.time_display {
|
let time_display = match flags.time_display {
|
||||||
TimeDisplayType::Absolute => format!("<t:{}>", self.utc_time.timestamp()),
|
TimeDisplayType::Absolute => timezone
|
||||||
|
.timestamp(self.utc_time.timestamp(), 0)
|
||||||
|
.format("%Y-%m-%d %H:%M:%S")
|
||||||
|
.to_string(),
|
||||||
|
|
||||||
TimeDisplayType::Relative => format!("<t:{}:R>", self.utc_time.timestamp()),
|
TimeDisplayType::Relative => format!("<t:{}:R>", self.utc_time.timestamp()),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(interval) = self.interval {
|
if let Some(interval) = self.interval {
|
||||||
format!(
|
format!(
|
||||||
"'{}' *{}* **{}**, repeating every **{}** (set by {})",
|
"'{}' *occurs next at* **{}**, repeating every **{}** (set by {})",
|
||||||
self.display_content(),
|
self.display_content(),
|
||||||
&inter,
|
|
||||||
time_display,
|
time_display,
|
||||||
longhand_displacement(interval as u64),
|
longhand_displacement(interval as u64),
|
||||||
self.set_by
|
self.set_by
|
||||||
@ -334,9 +337,8 @@ WHERE
|
|||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
format!(
|
format!(
|
||||||
"'{}' *{}* **{}** (set by {})",
|
"'{}' *occurs next at* **{}** (set by {})",
|
||||||
self.display_content(),
|
self.display_content(),
|
||||||
&inter,
|
|
||||||
time_display,
|
time_display,
|
||||||
self.set_by
|
self.set_by
|
||||||
.map(|i| format!("<@{}>", i))
|
.map(|i| format!("<@{}>", i))
|
||||||
|
Loading…
Reference in New Issue
Block a user