mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
修复定时、时间戳bug
This commit is contained in:
@@ -359,12 +359,12 @@ function handleDataBeforeReturn(db) {
|
||||
const currentTimestamp = Date.now()
|
||||
const startTimestamp = getTimestamp(
|
||||
p.date.start_date,
|
||||
p.date.start_time,
|
||||
p.date.start_time || '00:00',
|
||||
p.date.time_zone
|
||||
)
|
||||
const endTimestamp = getTimestamp(
|
||||
p.date.end_date,
|
||||
p.date.end_time,
|
||||
p.date.end_time || '23:59',
|
||||
p.date.time_zone
|
||||
)
|
||||
console.log(
|
||||
@@ -694,7 +694,7 @@ function isInRange(title, date = {}) {
|
||||
* @param {string} timeZone - 时区名称(如 "Asia/Shanghai")
|
||||
* @returns {Date} - 转换后的 Date 对象(UTC 时间)
|
||||
*/
|
||||
function convertToUTC(dateStr, timeZone) {
|
||||
function convertToUTC(dateStr, timeZone = 'Asia/Shanghai') {
|
||||
// 维护一个时区偏移映射(以小时为单位)
|
||||
const timeZoneOffsets = {
|
||||
// UTC 基础
|
||||
@@ -766,7 +766,7 @@ function convertToUTC(dateStr, timeZone) {
|
||||
}
|
||||
|
||||
// 辅助函数:生成指定日期时间的时间戳(基于目标时区)
|
||||
function getTimestamp(date, time, time_zone) {
|
||||
function getTimestamp(date, time ='00:00', time_zone) {
|
||||
if (!date) return null
|
||||
return convertToUTC(`${date} ${time}:00`, time_zone).getTime()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user