如何从时区名称(美国东部标准时间/印度标准时间)获取时区偏移量?
How to get timezone offset from timezone name (US Eastern Standard Time / India standard time)?
这是否有效从缩写如 IST 等中获得偏移量?
Is this valid to get offset from abbreviation like IST?
我不会说 "valid",但是 "innacurate"。
像 IST 这样的缩写是 ambiguous. IST is used in India, Israel and Ireland,每个都有不同的偏移量。
不仅如此,每个时区实际上都是历史(过去、现在和未来)期间的偏移量列表。即使印度今天使用 +05:30,in the 40's there were lots of changes:在某些时期,偏移量是 +06:30,因此根据您询问的地点和时间,您可能会得到不同的偏移量。
因此,要获得偏移量,您需要两件事:
- 实际,non-ambiguous时区名称,as defined by IANA,如
Asia/Kolkata
- 一个参考日期,用于获取该时区在特定时刻使用的偏移量
您可以使用 moment.tz's utcOffset
method 获取特定时区在特定时刻的偏移量。
PS:即使是"US Eastern Standard Time"这样的名字也不好用,因为这是一个非常综合的概念:EST covers lots of different places (hence, more than one IANA's timezone,在DST期间它变成了EDT(东部夏令时)。但有些地方没有夏令时,全年都使用美国东部标准时间。解决这个问题的唯一方法是使用正确的 IANA 时区标识符(例如 America/New_York
)。
这是否有效从缩写如 IST 等中获得偏移量?
Is this valid to get offset from abbreviation like IST?
我不会说 "valid",但是 "innacurate"。
像 IST 这样的缩写是 ambiguous. IST is used in India, Israel and Ireland,每个都有不同的偏移量。
不仅如此,每个时区实际上都是历史(过去、现在和未来)期间的偏移量列表。即使印度今天使用 +05:30,in the 40's there were lots of changes:在某些时期,偏移量是 +06:30,因此根据您询问的地点和时间,您可能会得到不同的偏移量。
因此,要获得偏移量,您需要两件事:
- 实际,non-ambiguous时区名称,as defined by IANA,如
Asia/Kolkata
- 一个参考日期,用于获取该时区在特定时刻使用的偏移量
您可以使用 moment.tz's utcOffset
method 获取特定时区在特定时刻的偏移量。
PS:即使是"US Eastern Standard Time"这样的名字也不好用,因为这是一个非常综合的概念:EST covers lots of different places (hence, more than one IANA's timezone,在DST期间它变成了EDT(东部夏令时)。但有些地方没有夏令时,全年都使用美国东部标准时间。解决这个问题的唯一方法是使用正确的 IANA 时区标识符(例如 America/New_York
)。