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

前端 未结 5 932
耶瑟儿~
耶瑟儿~ 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:48

    If using the datetime module, date, time, and datetime objects all have a min and max attribute.

    >>> from datetime import date, time, datetime
    >>> date.min
    datetime.date(1, 1, 1)
    >>> date.max
    datetime.date(9999, 12, 31)
    >>> time.min
    datetime.time(0, 0)
    >>> time.max
    datetime.time(23, 59, 59, 999999)
    >>> datetime.min
    datetime.datetime(1, 1, 1, 0, 0)
    >>> datetime.max
    datetime.datetime(9999, 12, 31, 23, 59, 59, 999999)
    

提交回复
热议问题