backup: snapshot before optimization

This commit is contained in:
2026-06-04 16:25:43 +08:00
commit ff2700c067
47 changed files with 3332 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
function formatTime(seconds) {
var m = Math.floor(seconds / 60)
var s = seconds % 60
return (m < 10 ? '0' : '') + m + ':' + (s < 10 ? '0' : '') + s
}
function formatDuration(seconds) {
if (seconds < 60) return seconds + '秒'
var m = Math.floor(seconds / 60)
var s = seconds % 60
return s > 0 ? m + '分' + s + '秒' : m + '分钟'
}
function getDaysInMonth(year, month) {
return new Date(year, month, 0).getDate()
}
function getMonthCalendar(year, month) {
var firstDay = new Date(year, month - 1, 1)
var lastDay = new Date(year, month, 0)
var daysInMonth = lastDay.getDate()
var startDayOfWeek = firstDay.getDay()
var weeks = []
var week = [null, null, null, null, null, null, null]
for (var d = 1; d <= daysInMonth; d++) {
var dow = (startDayOfWeek + d - 1) % 7
week[dow] = d
if (dow === 6 || d === daysInMonth) {
weeks.push(week.slice())
week = [null, null, null, null, null, null, null]
}
}
return weeks
}
module.exports = {
formatTime: formatTime,
formatDuration: formatDuration,
getDaysInMonth: getDaysInMonth,
getMonthCalendar: getMonthCalendar
}