fix(tl): deprecate date parsing
Build and Push Image / build-backend (push) Successful in 4m48s
Build and Push Image / build-frontend (push) Successful in 6m28s
Build and Push Image / push (push) Successful in 1m17s

This commit is contained in:
2026-08-06 12:08:17 +07:00 Unverified
parent 8c14999c59
commit 7be3db93b4
+19 -1
View File
@@ -103,7 +103,7 @@ async function buildLiveTierlistConfig(
}
function shouldSnapshot(config: TierlistResolvedConfig) {
const deprecatedAt = Date.parse(config.version.deprecates);
const deprecatedAt = parseDate(config.version.deprecates);
const olderThanMonth =
Number.isFinite(deprecatedAt) &&
deprecatedAt <= Date.now() - 30 * 24 * 60 * 60 * 1000;
@@ -120,6 +120,24 @@ function shouldSnapshot(config: TierlistResolvedConfig) {
return olderThanMonth || allTiered;
}
function parseDate(value: string) {
const match = value.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
if (!match) return Number.NaN;
const [, day, month, year] = match;
const date = new Date(Number(year), Number(month) - 1, Number(day));
if (
date.getFullYear() !== Number(year) ||
date.getMonth() !== Number(month) - 1 ||
date.getDate() !== Number(day)
) {
return Number.NaN;
}
return date.getTime();
}
async function maybeSnapshotVersion(
tx: DbLike,
version: typeof tierlistVersions.$inferSelect,