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() !== "") {
|
if (comingWhenRaw && comingWhenRaw.trim() !== "") {
|
||||||
let epoch: number | null = null;
|
let epoch: number | null = null;
|
||||||
const trimmed = comingWhenRaw.trim();
|
const trimmed = comingWhenRaw.trim();
|
||||||
|
if (trimmed.toLowerCase() === "soon") {
|
||||||
|
fields.push({
|
||||||
|
name: "📅 Coming On",
|
||||||
|
value: "Soon™",
|
||||||
|
inline: false,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
// Try DD/MM/YYYY
|
// Try DD/MM/YYYY
|
||||||
const ddmmyyyy = /^(\d{2})\/(\d{2})\/(\d{4})$/.exec(
|
const ddmmyyyy = /^(\d{2})\/(\d{2})\/(\d{4})$/.exec(
|
||||||
trimmed,
|
trimmed,
|
||||||
@@ -139,6 +146,7 @@ export default async function (_client: Client) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fields.push({
|
fields.push({
|
||||||
name: "🔗 More Info",
|
name: "🔗 More Info",
|
||||||
|
|||||||
@@ -128,7 +128,16 @@ export default async function (_client: Client) {
|
|||||||
if (comingWhenRaw && comingWhenRaw.trim() !== "") {
|
if (comingWhenRaw && comingWhenRaw.trim() !== "") {
|
||||||
let epoch: number | null = null;
|
let epoch: number | null = null;
|
||||||
const trimmed = comingWhenRaw.trim();
|
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) {
|
if (ddmmyyyy) {
|
||||||
const [, dd, mm, yyyy] = ddmmyyyy;
|
const [, dd, mm, yyyy] = ddmmyyyy;
|
||||||
const date = new Date(
|
const date = new Date(
|
||||||
@@ -155,6 +164,7 @@ export default async function (_client: Client) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fields.push({
|
fields.push({
|
||||||
name: "🔗 More Info",
|
name: "🔗 More Info",
|
||||||
|
|||||||
Reference in New Issue
Block a user