outlook-mcp/utils/timezone-mapper.js

136 lines
5.7 KiB
JavaScript

/**
* Small Windows timezone name -> IANA timezone name mapper.
*
* MS_TIMEZONE is documented to accept either IANA names (e.g. "America/New_York")
* or Windows names (e.g. "Eastern Standard Time"). Intl.DateTimeFormat only
* understands IANA identifiers, so we normalize Windows names before use.
*/
const WINDOWS_TO_IANA = {
'dateline standard time': 'Etc/GMT+12',
'utc-11': 'Etc/GMT+11',
'aleutian standard time': 'America/Adak',
'hawaiian standard time': 'Pacific/Honolulu',
'marquesas standard time': 'Pacific/Marquesas',
'alaskan standard time': 'America/Anchorage',
'utc-09': 'Etc/GMT+9',
'pacific standard time (mexico)': 'America/Tijuana',
'utc-08': 'Etc/GMT+8',
'pacific standard time': 'America/Los_Angeles',
'us mountain standard time': 'America/Phoenix',
'mountain standard time (mexico)': 'America/Chihuahua',
'mountain standard time': 'America/Denver',
'central america standard time': 'America/Guatemala',
'central standard time': 'America/Chicago',
'central standard time (mexico)': 'America/Mexico_City',
'canada central standard time': 'America/Regina',
'sa pacific standard time': 'America/Bogota',
'eastern standard time': 'America/New_York',
'us eastern standard time': 'America/Indianapolis',
'venezuela standard time': 'America/Caracas',
'paraguay standard time': 'America/Asuncion',
'atlantic standard time': 'America/Halifax',
'central brazilian standard time': 'America/Cuiaba',
'sa western standard time': 'America/La_Paz',
'pacific sa standard time': 'America/Santiago',
'newfoundland standard time': 'America/St_Johns',
'e. south america standard time': 'America/Sao_Paulo',
'argentina standard time': 'America/Buenos_Aires',
'greenland standard time': 'America/Godthab',
'montevideo standard time': 'America/Montevideo',
'bahia standard time': 'America/Bahia',
'utc-02': 'Etc/GMT+2',
'mid-atlantic standard time': 'Etc/GMT+2',
'azores standard time': 'Atlantic/Azores',
'cape verde standard time': 'Atlantic/Cape_Verde',
'utc': 'UTC',
'gmt standard time': 'Europe/London',
'greenwich standard time': 'Etc/GMT',
'w. europe standard time': 'Europe/Berlin',
'central europe standard time': 'Europe/Budapest',
'romance standard time': 'Europe/Paris',
'w. central africa standard time': 'Africa/Lagos',
'jordan standard time': 'Asia/Amman',
'gtb standard time': 'Europe/Athens',
'middle east standard time': 'Asia/Beirut',
'egypt standard time': 'Africa/Cairo',
'e. europe standard time': 'Europe/Chisinau',
'syria standard time': 'Asia/Damascus',
'west bank standard time': 'Asia/Hebron',
'south africa standard time': 'Africa/Johannesburg',
'fle standard time': 'Europe/Kiev',
'israel standard time': 'Asia/Jerusalem',
'kaliningrad standard time': 'Europe/Kaliningrad',
'libya standard time': 'Africa/Tripoli',
'arabic standard time': 'Asia/Baghdad',
'turkey standard time': 'Europe/Istanbul',
'arab standard time': 'Asia/Riyadh',
'belarus standard time': 'Europe/Minsk',
'russian standard time': 'Europe/Moscow',
'e. africa standard time': 'Africa/Nairobi',
'iran standard time': 'Asia/Tehran',
'arabian standard time': 'Asia/Dubai',
'azerbaijan standard time': 'Asia/Baku',
'caucasus standard time': 'Asia/Yerevan',
'mauritius standard time': 'Indian/Mauritius',
'georgian standard time': 'Asia/Tbilisi',
'caucasus standard time': 'Asia/Yerevan',
'afghanistan standard time': 'Asia/Kabul',
'west asia standard time': 'Asia/Tashkent',
'ekaterinburg standard time': 'Asia/Yekaterinburg',
'pakistan standard time': 'Asia/Karachi',
'india standard time': 'Asia/Kolkata',
'sri lanka standard time': 'Asia/Colombo',
'nepal standard time': 'Asia/Kathmandu',
'central asia standard time': 'Asia/Almaty',
'bangladesh standard time': 'Asia/Dhaka',
'myanmar standard time': 'Asia/Yangon',
'se asia standard time': 'Asia/Bangkok',
'north asia standard time': 'Asia/Krasnoyarsk',
'china standard time': 'Asia/Shanghai',
'north asia east standard time': 'Asia/Irkutsk',
'singapore standard time': 'Asia/Singapore',
'w. australia standard time': 'Australia/Perth',
'taipei standard time': 'Asia/Taipei',
'ulaanbaatar standard time': 'Asia/Ulaanbaatar',
'tokyo standard time': 'Asia/Tokyo',
'korea standard time': 'Asia/Seoul',
'yakutsk standard time': 'Asia/Yakutsk',
'cen. australia standard time': 'Australia/Adelaide',
'aus central standard time': 'Australia/Darwin',
'e. australia standard time': 'Australia/Brisbane',
'aus eastern standard time': 'Australia/Sydney',
'west pacific standard time': 'Pacific/Port_Moresby',
'tasmania standard time': 'Australia/Hobart',
'vladivostok standard time': 'Asia/Vladivostok',
'russia time zone 10': 'Asia/Srednekolymsk',
'central pacific standard time': 'Pacific/Guadalcanal',
'russia time zone 11': 'Asia/Kamchatka',
'new zealand standard time': 'Pacific/Auckland',
'utc+12': 'Etc/GMT-12',
'fiji standard time': 'Pacific/Fiji',
'tonga standard time': 'Pacific/Tongatapu',
'samoa standard time': 'Pacific/Apia',
'line islands standard time': 'Pacific/Kiritimati'
};
function windowsToIana(windowsName) {
if (!windowsName) return windowsName;
const normalized = String(windowsName).trim().toLowerCase();
return WINDOWS_TO_IANA[normalized] || windowsName;
}
/**
* Normalize a configured timezone name for use with Intl.DateTimeFormat.
* MS_TIMEZONE may be an IANA name (returned as-is) or a Windows name (mapped).
* @param {string} [timeZone] - Timezone name (defaults to config.DEFAULT_TIMEZONE)
* @returns {string}
*/
function resolveTimeZone(timeZone = require('../config').DEFAULT_TIMEZONE) {
return windowsToIana(timeZone);
}
module.exports = {
WINDOWS_TO_IANA,
windowsToIana,
resolveTimeZone
};