datetime是否解释了1750年的日历(新样式)法案?

2024-06-26 07:10:49 发布

您现在位置:Python中文网/ 问答频道 /正文

1752年9月,根据1750年的历法(新法),1752年9月跳过了11天。这可以通过Unix-cal命令看到。你知道吗

$ cal 9 1752
September 1752
Su Mo Tu We Th Fr Sa
1 2 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

在学习了这个factoid之后,我想知道Python的datetime类是否解释了这一点。经过一番快速的玩弄,它似乎没有。。。你知道吗

>>> datetime.datetime.now() - datetime.datetime(1752, 9, 14)
datetime.timedelta(96550, 47314, 535334)
>>> datetime.datetime.now() - datetime.datetime(1752, 9, 2)
datetime.timedelta(96562, 47318, 183610)

根据我的理解,如果1752年9月14日是96550天前,那么1752年9月2日应该是96551天前(因为3-13被跳过)。你知道吗

我也似乎日历类也不考虑跳过

>>> calendar.prmonth(1752, 9)
   September 1752
Mo Tu We Th Fr Sa Su
             1  2  3
 4  5  6  7  8  9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30

这在绝大多数应用程序中可能是无关紧要的,但是在我看来,这似乎仍然是一个错误,没有考虑到。当然,我也完全有可能遗漏了一些明显的东西。你知道吗

我是不是漏掉了什么明显的东西?你知道吗


Tags: datetimesaunixfrnowsutimedeltacal
1条回答
网友
1楼 · 发布于 2024-06-26 07:10:49

python日历被描述为here,它说:

Most of these functions and classes rely on the datetime module which uses an idealized calendar, the current Gregorian calendar indefinitely extended in both directions. This matches the definition of the “proleptic Gregorian” calendar in Dershowitz and Reingold’s book “Calendrical Calculations”, where it’s the base calendar for all computations.

所以不,英格兰在1752年决定使用公历(就像西欧其他国家一样)而不是儒略历,这并没有反映在Python使用的历法中。我很感兴趣的是Unix cal命令中确实包含了这个开关。你知道吗

相关问题 更多 >