每日运势小程序

This commit is contained in:
cjd
2025-11-09 18:41:07 +08:00
parent 1cc0241cda
commit abd82782af
34 changed files with 2204 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
function pad(num) {
return `${num}`.padStart(2, "0");
}
function formatDate(date) {
const target = date instanceof Date ? date : new Date(date);
return `${target.getFullYear()}-${pad(target.getMonth() + 1)}-${pad(target.getDate())}`;
}
function formatDisplayDateTime(value) {
if (!value) {
return "";
}
try {
const target = new Date(value);
return `${target.getFullYear()}-${pad(target.getMonth() + 1)}-${pad(target.getDate())} ${pad(target.getHours())}:${pad(
target.getMinutes()
)}`;
} catch (error) {
return value;
}
}
module.exports = {
formatDate,
formatDisplayDateTime
};