What is the oldest time that can be represented in Python?

前端 未结 5 920
耶瑟儿~
耶瑟儿~ 2021-02-06 21:40

I have written a function comp(time1, time2) which will return True when time1 is less than time2. I have a scenario where

5条回答
  •  后悔当初
    2021-02-06 21:52

    Certain functions in the datetime module obey datetime.MINYEAR and datetime.MAXYEAR and will raise a ValueException for dates outside that range. These are assigned to 1 and 9999, respectively.

    The calender module relies heavily on the datetime module, but in general, observes the “proleptic Gregorian”, which extends indefinately in both directions.

    the time module similarly places no particular restrictions on year elements in time tuple values, and calculates times and dates using only seconds since the epoch.


    That being said, you cannot reliably process dates before about February 12, 1582, when the Gregorian calender was adopted. Before that day, dates were computed using a variety of location dependent calenders, for which there is no support in standard python.

提交回复
热议问题