Skip to content

Commit 1c2013d

Browse files
committed
修复定时、时间戳bug
1 parent eff5b4c commit 1c2013d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/db/getSiteData.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,12 @@ function handleDataBeforeReturn(db) {
359359
const currentTimestamp = Date.now()
360360
const startTimestamp = getTimestamp(
361361
p.date.start_date,
362-
p.date.start_time,
362+
p.date.start_time || '00:00',
363363
p.date.time_zone
364364
)
365365
const endTimestamp = getTimestamp(
366366
p.date.end_date,
367-
p.date.end_time,
367+
p.date.end_time || '23:59',
368368
p.date.time_zone
369369
)
370370
console.log(
@@ -694,7 +694,7 @@ function isInRange(title, date = {}) {
694694
* @param {string} timeZone - 时区名称(如 "Asia/Shanghai")
695695
* @returns {Date} - 转换后的 Date 对象(UTC 时间)
696696
*/
697-
function convertToUTC(dateStr, timeZone) {
697+
function convertToUTC(dateStr, timeZone = 'Asia/Shanghai') {
698698
// 维护一个时区偏移映射(以小时为单位)
699699
const timeZoneOffsets = {
700700
// UTC 基础
@@ -766,7 +766,7 @@ function convertToUTC(dateStr, timeZone) {
766766
}
767767

768768
// 辅助函数:生成指定日期时间的时间戳(基于目标时区)
769-
function getTimestamp(date, time, time_zone) {
769+
function getTimestamp(date, time ='00:00', time_zone) {
770770
if (!date) return null
771771
return convertToUTC(`${date} ${time}:00`, time_zone).getTime()
772772
}

0 commit comments

Comments
 (0)