Fix character counting on /look. Initial support for jumping over DST boundaries
This commit is contained in:
parent
e9792e6322
commit
6e087bd2dd
1031
Cargo.lock
generated
1031
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -14,7 +14,7 @@ regex = "1.6"
|
||||
log = "0.4"
|
||||
env_logger = "0.9"
|
||||
chrono = "0.4"
|
||||
chrono-tz = { version = "0.6", features = ["serde"] }
|
||||
chrono-tz = { version = "0.8", features = ["serde"] }
|
||||
lazy_static = "1.4"
|
||||
num-integer = "0.1"
|
||||
serde = "1.0"
|
||||
|
@ -1,4 +1,4 @@
|
||||
use chrono::Duration;
|
||||
use chrono::{DateTime, Days, Duration};
|
||||
use chrono_tz::Tz;
|
||||
use lazy_static::lazy_static;
|
||||
use log::{error, info, warn};
|
||||
@ -374,7 +374,30 @@ UPDATE channels SET webhook_id = NULL, webhook_token = NULL WHERE channel = ?
|
||||
}
|
||||
}
|
||||
|
||||
fn increment_days(
|
||||
now: NaiveDateTime,
|
||||
mut new_time: NaiveDateTime,
|
||||
interval: u32,
|
||||
) -> Option<NaiveDateTime> {
|
||||
while new_time < now {
|
||||
new_time = new_time.checked_add_days(Days::new((interval / 86400).into()))?;
|
||||
}
|
||||
|
||||
Some(new_time)
|
||||
}
|
||||
|
||||
if let Some(interval) = self.interval_seconds {
|
||||
if interval.div_rem(&86400).1 == 0 {
|
||||
updated_reminder_time =
|
||||
match increment_days(now, updated_reminder_time, interval) {
|
||||
Some(d) => d,
|
||||
None => {
|
||||
warn!("Failed to update days on a reminder.");
|
||||
updated_reminder_time
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while updated_reminder_time < now {
|
||||
updated_reminder_time += Duration::seconds(interval as i64);
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ pub async fn look(
|
||||
char_count < EMBED_DESCRIPTION_MAX_LENGTH
|
||||
})
|
||||
.collect::<Vec<String>>()
|
||||
.join("\n");
|
||||
.join("");
|
||||
|
||||
let pages = reminders
|
||||
.iter()
|
||||
|
@ -113,7 +113,7 @@ impl ComponentDataModel {
|
||||
char_count < EMBED_DESCRIPTION_MAX_LENGTH
|
||||
})
|
||||
.collect::<Vec<String>>()
|
||||
.join("\n");
|
||||
.join("");
|
||||
|
||||
let mut embed = CreateEmbed::default();
|
||||
embed
|
||||
|
@ -326,14 +326,14 @@ WHERE
|
||||
|
||||
if self.interval_seconds.is_some() || self.interval_months.is_some() {
|
||||
format!(
|
||||
"'{}' *occurs next at* **{}**, repeating (set by {})",
|
||||
"'{}' *occurs next at* **{}**, repeating (set by {})\n",
|
||||
self.display_content(),
|
||||
time_display,
|
||||
self.set_by.map(|i| format!("<@{}>", i)).unwrap_or_else(|| "unknown".to_string())
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
"'{}' *occurs next at* **{}** (set by {})",
|
||||
"'{}' *occurs next at* **{}** (set by {})\n",
|
||||
self.display_content(),
|
||||
time_display,
|
||||
self.set_by.map(|i| format!("<@{}>", i)).unwrap_or_else(|| "unknown".to_string())
|
||||
|
Loading…
Reference in New Issue
Block a user