refactor announcement date handling to support 'soon' and streamline date parsing logic
All checks were successful
CI / build (push) Successful in 9s

This commit is contained in:
Space-Banane
2026-02-22 16:59:24 +01:00
parent d3c15c526b
commit f010255944
2 changed files with 62 additions and 44 deletions

View File

@@ -108,6 +108,13 @@ export default async function (_client: Client) {
if (comingWhenRaw && comingWhenRaw.trim() !== "") {
let epoch: number | null = null;
const trimmed = comingWhenRaw.trim();
if (trimmed.toLowerCase() === "soon") {
fields.push({
name: "📅 Coming On",
value: "Soon™",
inline: false,
});
} else {
// Try DD/MM/YYYY
const ddmmyyyy = /^(\d{2})\/(\d{2})\/(\d{4})$/.exec(
trimmed,
@@ -139,6 +146,7 @@ export default async function (_client: Client) {
});
}
}
}
fields.push({
name: "🔗 More Info",

View File

@@ -128,7 +128,16 @@ export default async function (_client: Client) {
if (comingWhenRaw && comingWhenRaw.trim() !== "") {
let epoch: number | null = null;
const trimmed = comingWhenRaw.trim();
const ddmmyyyy = /^(\d{2})\/(\d{2})\/(\d{4})$/.exec(trimmed);
if (trimmed.toLowerCase() === "soon") {
fields.push({
name: "📅 Coming On",
value: "Soon™",
inline: false,
});
} else {
const ddmmyyyy = /^(\d{2})\/(\d{2})\/(\d{4})$/.exec(
trimmed,
);
if (ddmmyyyy) {
const [, dd, mm, yyyy] = ddmmyyyy;
const date = new Date(
@@ -155,6 +164,7 @@ export default async function (_client: Client) {
});
}
}
}
fields.push({
name: "🔗 More Info",