fix: time related issues #179

Merged
Anri merged 5 commits from fix-time into main 2024-09-24 18:07:27 +02:00
3 changed files with 14 additions and 11 deletions
Showing only changes of commit f7d7b66cf6 - Show all commits

View file

@ -133,9 +133,17 @@ export default async (message: Message, client: Client) => {
} }
// Footer // Footer
let footer = `Posté le ${showDate(loc, quoted_post.createdAt)}`; let footer = `Posté le ${showDate(
message.guild?.preferredLocale ?? client.config.default_lang,
loc,
quoted_post.createdAt,
)}`;
if (quoted_post.editedAt) { if (quoted_post.editedAt) {
footer += ` et modifié le ${showDate(loc, quoted_post.editedAt)}`; footer += ` et modifié le ${showDate(
message.guild?.preferredLocale ?? client.config.default_lang,
loc,
quoted_post.editedAt,
)}`;
} }
let author = "Auteur"; let author = "Auteur";
@ -143,6 +151,7 @@ export default async (message: Message, client: Client) => {
author += " & Citateur"; author += " & Citateur";
} else { } else {
footer += `\nCité par ${userWithNickname(message.member!) ?? "?"} le ${showDate( footer += `\nCité par ${userWithNickname(message.member!) ?? "?"} le ${showDate(
message.guild?.preferredLocale ?? client.config.default_lang,
loc, loc,
message.createdAt, message.createdAt,
)}`; )}`;

View file

@ -414,6 +414,7 @@ export const embedListReminders = async (
const expiration = `${loc.get("c_reminder8")} ${timeDeltaToString(remind.expiration_date)}`; const expiration = `${loc.get("c_reminder8")} ${timeDeltaToString(remind.expiration_date)}`;
embed.addFields({ embed.addFields({
name: `#${remind.id}${loc.get("c_reminder9")} ${showDate( name: `#${remind.id}${loc.get("c_reminder9")} ${showDate(
local,
loc, loc,
new Date(Number(remind.creation_date)), new Date(Number(remind.creation_date)),
)}\n${expiration}`, )}\n${expiration}`,

View file

@ -5,15 +5,8 @@
* @param date Date * @param date Date
* @returns String * @returns String
*/ */
export const showDate = (locale: Map<string, unknown>, date: Date) => { export const showDate = (tz: string, locale: Map<string, unknown>, date: Date) =>
const timezoned = new Date(date.getTime() + date.getTimezoneOffset() * 60000); date.toLocaleString(tz).replace(" ", ` ${locale.get("u_time_at")} `);
console.log(date.getTimezoneOffset());
return `${timezoned.toDateString()} ${locale.get("u_time_at")} ${
timezoned.toTimeString().split(" ")[0]
}`;
};
enum TimeSecond { enum TimeSecond {
Year = 31536000, Year = 31536000,