Postgresql 中文操作指南
B.6. History of Units #
SQL 标准规定,“在“日期时间文字”的定义中,“日期时间值”受到公历对日期和时间的自然规则的约束”。PostgreSQL 遵循 SQL 标准的指示,即使在该日历使用之前,也仅在公历中计算日期。此规则称为 proleptic Gregorian calendar。
The SQL standard states that “Within the definition of a ‘datetime literal’, the ‘datetime values’ are constrained by the natural rules for dates and times according to the Gregorian calendar”. PostgreSQL follows the SQL standard’s lead by counting dates exclusively in the Gregorian calendar, even for years before that calendar was in use. This rule is known as the proleptic Gregorian calendar.
儒略历由儒略·凯撒于公元前 45 年引入。在 1582 年国家开始转换为公历之前,它在西方世界中普遍使用。在儒略历中,回归年近似为 365 1/4 天 = 365.25 天。这在 128 年中产生大约 1 天的误差。
The Julian calendar was introduced by Julius Caesar in 45 BC. It was in common use in the Western world until the year 1582, when countries started changing to the Gregorian calendar. In the Julian calendar, the tropical year is approximated as 365 1/4 days = 365.25 days. This gives an error of about 1 day in 128 years.
累积的日历误差促使教皇格里高利十三世根据特伦特会议的指示改革日历。在公历中,回归年近似为 365 + 97 / 400 天 = 365.2425 天。因此,回归年大约需要 3300 年才能相对于公历移动一天。
The accumulating calendar error prompted Pope Gregory XIII to reform the calendar in accordance with instructions from the Council of Trent. In the Gregorian calendar, the tropical year is approximated as 365 + 97 / 400 days = 365.2425 days. Thus it takes approximately 3300 years for the tropical year to shift one day with respect to the Gregorian calendar.
近似值 365+97/400 是通过使用以下规则在 400 年内有 97 个闰年来实现的:
The approximation 365+97/400 is achieved by having 97 leap years every 400 years, using the following rules:
因此,1700、1800、1900、2100 和 2200 不是闰年。但是,1600、2000 和 2400 是闰年。相比之下,在较早的儒略历中,所有 4 的倍数都是闰年。
So, 1700, 1800, 1900, 2100, and 2200 are not leap years. But 1600, 2000, and 2400 are leap years. By contrast, in the older Julian calendar all years divisible by 4 are leap years.
1582 年 2 月的教皇诏书规定,10 月 1582 年应减少 10 天,以便 10 月 15 日应紧接在 10 月 4 日之后。在意大利、波兰、葡萄牙和西班牙都遵守了这一点。其他天主教国家很快也效仿,但新教国家不愿改变,希腊东正教国家直到 20 世纪初才改变。1752 年,大不列颠及其领地(包括现在的美国)遵守了这项改革。因此,1752 年 9 月 2 日之后是 1752 年 9 月 14 日。这就是有 cal 程序的 Unix 系统产生以下内容的原因:
The papal bull of February 1582 decreed that 10 days should be dropped from October 1582 so that 15 October should follow immediately after 4 October. This was observed in Italy, Poland, Portugal, and Spain. Other Catholic countries followed shortly after, but Protestant countries were reluctant to change, and the Greek Orthodox countries didn’t change until the start of the 20th century. The reform was observed by Great Britain and its dominions (including what is now the USA) in 1752. Thus 2 September 1752 was followed by 14 September 1752. This is why Unix systems that have the cal program produce the following:
$ cal 9 1752
September 1752
S M Tu W Th F S
1 2 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
但是,当然,此日历仅对大不列颠及其领地有效,对其他地方无效。由于尝试跟踪各个地方在不同时间实际使用的实际日历会很困难且令人困惑,因此 PostgreSQL 不会尝试这样做,而只会遵循所有日期的公历规则,即使这种方法在历史上不准确。
But, of course, this calendar is only valid for Great Britain and dominions, not other places. Since it would be difficult and confusing to try to track the actual calendars that were in use in various places at various times, PostgreSQL does not try, but rather follows the Gregorian calendar rules for all dates, even though this method is not historically accurate.
世界上不同的地方已经制定了不同的日历,其中许多日历早于公历系统。例如,中国日历的起源可以追溯到公元前 14 世纪。传说皇帝黄帝在公元前 2637 年发明了该日历。中华人民共和国出于民事目的使用公历。中国农历用于确定节假日。
Different calendars have been developed in various parts of the world, many predating the Gregorian system. For example, the beginnings of the Chinese calendar can be traced back to the 14th century BC. Legend has it that the Emperor Huangdi invented that calendar in 2637 BC. The People’s Republic of China uses the Gregorian calendar for civil purposes. The Chinese calendar is used for determining festivals.