mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
support Taipei
This commit is contained in:
@@ -704,6 +704,7 @@ function convertToUTC(dateStr, timeZone = 'Asia/Shanghai') {
|
||||
|
||||
// 亚洲地区
|
||||
'Asia/Shanghai': 8, // 中国
|
||||
'Asia/Taipei': 8, // 台湾
|
||||
'Asia/Tokyo': 9, // 日本
|
||||
'Asia/Seoul': 9, // 韩国
|
||||
'Asia/Kolkata': 5.5, // 印度
|
||||
@@ -711,6 +712,9 @@ function convertToUTC(dateStr, timeZone = 'Asia/Shanghai') {
|
||||
'Asia/Singapore': 8, // 新加坡
|
||||
'Asia/Hong_Kong': 8, // 香港
|
||||
'Asia/Bangkok': 7, // 泰国
|
||||
'Asia/Dubai': 4, // 阿联酋
|
||||
'Asia/Tehran': 3.5, // 伊朗
|
||||
'Asia/Riyadh': 3, // 沙特阿拉伯
|
||||
|
||||
// 欧洲地区
|
||||
'Europe/London': 0, // 英国(GMT)
|
||||
@@ -738,20 +742,38 @@ function convertToUTC(dateStr, timeZone = 'Asia/Shanghai') {
|
||||
'Pacific/Auckland': 13, // 新西兰
|
||||
'Pacific/Fiji': 12, // 斐济
|
||||
|
||||
// 中东地区
|
||||
'Asia/Dubai': 4, // 阿联酋
|
||||
'Asia/Tehran': 3.5, // 伊朗
|
||||
'Asia/Riyadh': 3, // 沙特阿拉伯
|
||||
|
||||
// 北极与南极
|
||||
'Antarctica/Palmer': -3, // 南极洲帕尔默
|
||||
'Antarctica/McMurdo': 13 // 南极洲麦克默多
|
||||
}
|
||||
|
||||
// 预设每个大洲的默认时区
|
||||
const continentDefaults = {
|
||||
Asia: 'Asia/Shanghai',
|
||||
Europe: 'Europe/London',
|
||||
America: 'America/New_York',
|
||||
Africa: 'Africa/Cairo',
|
||||
Australia: 'Australia/Sydney',
|
||||
Pacific: 'Pacific/Auckland',
|
||||
Antarctica: 'Antarctica/Palmer',
|
||||
UTC: 'UTC'
|
||||
}
|
||||
|
||||
// 获取目标时区的偏移量(以小时为单位)
|
||||
const offsetHours = timeZoneOffsets[timeZone]
|
||||
let offsetHours = timeZoneOffsets[timeZone]
|
||||
|
||||
// 未被支持的时区采用兼容
|
||||
if (offsetHours === undefined) {
|
||||
throw new Error(`Unsupported time zone: ${timeZone}`)
|
||||
// 获取时区所属大洲("Continent/City" -> "Continent")
|
||||
const continent = timeZone.split('/')[0]
|
||||
|
||||
// 选择该大洲的默认时区
|
||||
const fallbackZone = continentDefaults[continent] || 'UTC'
|
||||
offsetHours = timeZoneOffsets[fallbackZone]
|
||||
|
||||
console.warn(
|
||||
`Warning: Unsupported time zone "${timeZone}". Using default "${fallbackZone}" for continent "${continent}".`
|
||||
)
|
||||
}
|
||||
|
||||
// 将日期字符串转换为本地时间的 Date 对象
|
||||
@@ -766,7 +788,7 @@ function convertToUTC(dateStr, timeZone = 'Asia/Shanghai') {
|
||||
}
|
||||
|
||||
// 辅助函数:生成指定日期时间的时间戳(基于目标时区)
|
||||
function getTimestamp(date, time ='00:00', 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