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]]
|
||||
name = "command_attr"
|
||||
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 = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -1481,7 +1481,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "serenity"
|
||||
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 = [
|
||||
"async-trait",
|
||||
"async-tungstenite",
|
||||
|
@ -214,9 +214,9 @@ async fn nudge(ctx: &Context, msg: &Message, args: String) {
|
||||
#[command("look")]
|
||||
#[permission_level(Managed)]
|
||||
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);
|
||||
|
||||
@ -237,14 +237,12 @@ async fn look(ctx: &Context, msg: &Message, args: String) {
|
||||
if reminders.is_empty() {
|
||||
let _ = msg
|
||||
.channel_id
|
||||
.say(&ctx, lm.get(&language, "look/no_reminders"))
|
||||
.say(&ctx, "No reminders on specified channel")
|
||||
.await;
|
||||
} else {
|
||||
let inter = lm.get(&language, "look/inter");
|
||||
|
||||
let display = reminders
|
||||
.iter()
|
||||
.map(|reminder| reminder.display(&flags, inter));
|
||||
.map(|reminder| reminder.display(&flags, &timezone));
|
||||
|
||||
let _ = msg.channel_id.say_lines(&ctx, display).await;
|
||||
}
|
||||
|
@ -9,7 +9,8 @@ use serenity::{
|
||||
model::id::{ChannelId, GuildId, UserId},
|
||||
};
|
||||
|
||||
use chrono::NaiveDateTime;
|
||||
use chrono::{NaiveDateTime, TimeZone};
|
||||
use chrono_tz::Tz;
|
||||
|
||||
use crate::{
|
||||
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 {
|
||||
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()),
|
||||
};
|
||||
|
||||
if let Some(interval) = self.interval {
|
||||
format!(
|
||||
"'{}' *{}* **{}**, repeating every **{}** (set by {})",
|
||||
"'{}' *occurs next at* **{}**, repeating every **{}** (set by {})",
|
||||
self.display_content(),
|
||||
&inter,
|
||||
time_display,
|
||||
longhand_displacement(interval as u64),
|
||||
self.set_by
|
||||
@ -334,9 +337,8 @@ WHERE
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
"'{}' *{}* **{}** (set by {})",
|
||||
"'{}' *occurs next at* **{}** (set by {})",
|
||||
self.display_content(),
|
||||
&inter,
|
||||
time_display,
|
||||
self.set_by
|
||||
.map(|i| format!("<@{}>", i))
|
||||
|
Loading…
Reference in New Issue
Block a user