6.7.0 - Alpha4 - 新增 JS 脚本工具 (run-scrapers.mjs)

This commit is contained in:
SuperMonster003
2025-09-09 17:24:48 +08:00
parent a997c7bbec
commit 9991ec3c28
56 changed files with 5167 additions and 752 deletions

23
.utils/utils/date.mjs Normal file
View File

@@ -0,0 +1,23 @@
// utils/date.mjs
/**
* @param {Date} [date=new Date()]
* @returns {string}
*/
export function toUpdatedStamp(date = new Date()) {
/* e.g. "Aug 23, 2025". */
return date.toLocaleString('en-US', { month: 'short', day: 'numeric', year: 'numeric' });
}
/**
* @param {string} [dateText='']
* @returns {string | null}
*/
export function toYYYYMMDD(dateText = '') {
const d = dateText ? new Date(dateText) : new Date();
if (Number.isNaN(d.getTime())) return null;
const y = d.getFullYear();
const m = String(d.getMonth() + 1).padStart(2, '0');
const day = String(d.getDate()).padStart(2, '0');
return `${y}/${m}/${day}`;
}