refactor announcement date handling to support 'soon' and streamline date parsing logic
All checks were successful
CI / build (push) Successful in 9s
All checks were successful
CI / build (push) Successful in 9s
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user