新建项目

This commit is contained in:
2026-07-29 10:50:33 +08:00
parent bfd3841cbd
commit 4f69b859a8
49 changed files with 5565 additions and 0 deletions

30
utils/format.js Normal file
View File

@@ -0,0 +1,30 @@
function pad(value) {
return String(value).padStart(2, "0");
}
function formatCountdown(totalSeconds) {
const safe = Math.max(0, Math.floor(totalSeconds || 0));
const minutes = Math.floor(safe / 60);
const seconds = safe % 60;
return `${pad(minutes)}:${pad(seconds)}`;
}
function formatTime(timestamp) {
const date = new Date(timestamp);
return `${pad(date.getHours())}:${pad(date.getMinutes())}`;
}
function randomCode() {
return String(Math.floor(100000 + Math.random() * 900000));
}
function clone(value) {
return JSON.parse(JSON.stringify(value));
}
module.exports = {
formatCountdown,
formatTime,
randomCode,
clone
};