为什么 Exasol 转换旧的时间戳会出错?

huangapple go评论119阅读模式
英文:

Why exasol transform old timestamp wrong?

问题

Exasol错误地转换了旧日期:

SELECT ADD_SECONDS('1970-01-01 00:00:00', -30610224000.000)
-- 0999-12-27 00:00:00

SELECT ADD_SECONDS('1970-01-01 00:00:00', -30609792000.000)
-- 1000-01-01 00:00:00

而在Java中:

System.out.println(Instant.ofEpochMilli(0).plus(-30610224000L, ChronoUnit.SECONDS));
System.out.println(Instant.ofEpochMilli(0).plus(-30609792000L, ChronoUnit.SECONDS));

结果分别是:

1000-01-01T00:00:00Z
1000-01-06T00:00:00Z

你知道这个差异的原因吗?

英文:

Exasol is transforming old dates incorrectly:

SELECT ADD_SECONDS('1970-01-01 00:00:00',-30610224000.000)
-- 0999-12-27 00:00:00

SELECT ADD_SECONDS('1970-01-01 00:00:00',-30609792000.000)
-- 1000-01-01 00:00:00

While in java:

  System.out.println(Instant.ofEpochMilli(0).plus(-30610224000L, ChronoUnit.SECONDS));
  System.out.println(Instant.ofEpochMilli(0).plus(-30609792000L, ChronoUnit.SECONDS));

1000-01-01T00:00:00Z
1000-01-06T00:00:00Z

Do you know why that diference?

答案1

得分: 2

不了解Exasol,我敢打赌这是朱利安历和普罗利普蒂克·格里高利历法之间的差异。

朱利安历(以朱利斯·凯撒命名)每4年总是有闰年。在历史的某一点上,他们发现这给了太多的闰年。因此,在教皇格里高利的领导下,引入了格里高利历,不在能被100整除但不能被400整除的年份加入闰年(因此1900年不是闰年,2000年是闰年,2100年不是)。这个变化被称为格里高利变革或变更。

普罗利普蒂克·格里高利历是一个较新的发明。它将格里高利历推算回格里高利变革之前的时期,因此使用的日期与实际在那些时期使用的历法不符。优点是计算更简单,并且我们不必决定何时进行格里高利变革,这很好,因为每个司法管辖区都有自己的日期。

java.time中的Instant和其他类使用普罗利普蒂克·格里高利历,因此对于公元999年和1000年的日期给出不准确的结果。如果Exasol使用朱利安历(我不清楚),这可能是您观察到的差异的解释。

链接

英文:

Not knowing Exasol I bet it’s the difference between the Julian and the proleptic Gregorian calendar.

The Julian calendar (named after Julius Caesar) has leap years every 4 years always. At a point in history they discovered that this gave a bit too many leap years. So under pope Gregor the Gregorian calendar was introduced, leaving out leap years for years that are divisible by 100 but not by 400 (so 1900 was not a leap year, 2000 was and 2100 will not be). The change is known as the Gregorian change or changeover.

The proleptic Gregorian calendar is a newer invention. It extrapolates the Gregorian calendar back into times before the Gregorian change, thus using dates that are in disagreement with the calendar actually used back in those times. The advantages being that calculations are simpler, and we are free from deciding when to make the Gregorian change, which is nice since each jurisdiction had their own date for that.

Instant and the other classes from java.time use the proleptic Gregorian calendar, so give inaccurate dates for years 999 and 1000. If Exasol uses the Julian calendar (which I do not know), this could be the explanation for the differences you observed.

Links

huangapple
  • 本文由 发表于 2020年9月9日 18:39:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/63809880.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定