为什么这么多IANA时区的名称? [英] Why So Many IANA Time Zones Names?

查看:1130
本文介绍了为什么这么多IANA时区的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您指定 IANA ,Javascript可让您查看其他时区的停留时间给出该时区的名称。例如:

Javascript allows you to see what time it is in another timezone if you specify the IANA given name of that timezone. For example:

new Date().toLocaleString("en-US", {timeZone: "America/Chicago"});

您可以看到IANA在每个常规时区内提供多个名称:

Below you can see that IANA provides multiple names within each general timezone:

America/New_York    Eastern (most areas)
America/Detroit Eastern - MI (most areas)
America/Kentucky/Louisville Eastern - KY (Louisville area)
America/Kentucky/Monticello Eastern - KY (Wayne)
America/Indiana/Indianapolis    Eastern - IN (most areas)
America/Indiana/Vincennes   Eastern - IN (Da, Du, K, Mn)
America/Indiana/Winamac Eastern - IN (Pulaski)
America/Indiana/Marengo Eastern - IN (Crawford)
America/Indiana/Petersburg  Eastern - IN (Pike)
America/Indiana/Vevay   Eastern - IN (Switzerland)
America/Chicago Central (most areas)
America/Indiana/Tell_City   Central - IN (Perry)
America/Indiana/Knox    Central - IN (Starke)
America/Menominee   Central - MI (Wisconsin border)
America/North_Dakota/Center Central - ND (Oliver)
America/North_Dakota/New_Salem  Central - ND (Morton rural)
America/North_Dakota/Beulah Central - ND (Mercer)
America/Denver  Mountain (most areas)
America/Boise   Mountain - ID (south); OR (east)
America/Phoenix MST - Arizona (except Navajo)
America/Los_Angeles Pacific
America/Anchorage   Alaska (most areas)
America/Juneau  Alaska - Juneau area
America/Sitka   Alaska - Sitka area
America/Metlakatla  Alaska - Annette Island
America/Yakutat Alaska - Yakutat
America/Nome    Alaska (west)
America/Adak    Aleutian Islands
Pacific/Honolulu    Hawaii

为什么需要?

例如, America / Detroit America / New_York (通常)都位于东部时区。为什么这两个位置不共享一个 IANA 时区名称?

For example, both America/Detroit and America/New_York are (generally) in the Eastern Time Zone. Why don't these two locations share a single IANA timezone name?

纽约的时间与底特律的时间有什么不同?

Are there occations of the year where the time in New York is different from that of Detroit?

如果没有,那么为什么允许更多的时区名称而不是确切的差异数?

推荐答案

我将使用你的例子:


例如,America / Detroit和America / New_York都在东部时区。为什么这两个位置不共享一个时区名称?

For example, both America/Detroit and America/New_York are in the Eastern Time Zone. Why don't these two locations share a single timezone name?

在TZDB中, 区域条目 America / New_York 如下所示:

In the TZDB, the Zone entry for America/New_York looks like this:

# Zone  NAME              GMTOFF    RULES   FORMAT   [UNTIL]
Zone    America/New_York  -4:56:02  -       LMT      1883 Nov 18 12:03:58
                          -5:00     US      E%sT     1920
                          -5:00     NYC     E%sT     1942
                          -5:00     US      E%sT     1946
                          -5:00     NYC     E%sT     1967
                          -5:00     US      E%sT

America / Detroit 区域条目如下所示:

# Zone  NAME              GMTOFF    RULES   FORMAT   [UNTIL]
Zone    America/Detroit   -5:32:11  -       LMT      1905
                          -6:00     -       CST      1915 May 15  2:00
                          -5:00     -       EST      1942
                          -5:00     US      E%sT     1946
                          -5:00     Detroit E%sT     1973
                          -5:00     US      E%sT     1975
                          -5:00     -       EST      1975 Apr 27  2:00
                          -5:00     US      E%sT

要完全解密这个,还需要规则条目.com / eggert / tz / blob / 2018i / northamerica#L150-L163rel =nofollow noreferrer> US NYC 底特律 (我不会复制/粘贴此处,但您可以点击链接)。

To fully decipher this, one also needs the Rule entries for US, NYC, and Detroit (which I won't copy/paste here, but you can follow the links).

正如你所看到的,底特律有一些来自纽约的变化,最后一次是在1975年底特律开始夏令时比东部大部分时区稍晚(4月27日在这里显示vs 2月23日由规则US提供)。

As you can see, Detroit has had variations from New York, the last of which was in 1975 when Detroit started daylight saving time slightly later than most of the Eastern time zone (Apr 27 shown here vs Feb 23rd given by Rule US).

然而,从那时起,它们是一样的。 TZDB规则要求对自1970年以来达成协议的区域建立一个独特区域,这些区域在1973年和1975年都有偏差,因此它们需要唯一的区域标识符。

Since then however, they have been the same. The TZDB rules require a unique zone for areas that have agreed since 1970, and these areas have deviations in 1973 and 1975, thus they require unique zone identifiers.

人们可以在JavaScript中看到这种差异:

One can see this difference in JavaScript like so:

var d = new Date("1975-03-01T00:00:00.000Z"); // Midnight UTC on March 1st
d.toLocaleString("en-US", {timeZone: "America/New_York"})  //=> "2/28/1975, 8:00:00 PM"
d.toLocaleString("en-US", {timeZone: "America/Detroit"})   //=> "2/28/1975, 7:00:00 PM"

当然,如果在你的应用程序,你永远不会处理那么久的日期,然后你可以使用 America / New_York 代表美国东部时区,并省略 America / Detroit (和其他一些人) - 但这完全是你的决定。

Of course, if in your application, you never deal with dates going back that far, then you can just use America/New_York to represent the US Eastern time zone, and omit America/Detroit (and a few others) - but this is entirely your decision to make.

你也可能是有兴趣阅读tzdb本身的 Theory 文件,它解释了这些概念和时区数据库的原则更详细。

You may also be interested in reading the Theory file with in the tzdb itself, which explains the concepts and principles of the time zone database in a lot more detail.

这篇关于为什么这么多IANA时区的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆