I have written a function comp(time1, time2)
which will return True
when time1
is less than time2
. I have a scenario where
If you're using the time
module, you have no guarantee, because it defers to C library functions on the platform that can handle implementation-defined minimum and maximum times. https://docs.python.org/3/library/time.html states:
Most of the functions defined in this module call platform C library functions with the same name. It may sometimes be helpful to consult the platform documentation, because the semantics of these functions varies among platforms.
and https://docs.python.org/3/library/time.html#time.mktime states:
The earliest date for which it can generate a time is platform-dependent.
That's because these functions take or return time_t
values, and per the C11 standard:
The range and precision of times representable in
clock_t
andtime_t
are implementation-defined.
Unlike the datetime
module, the time
module does not expose any constants indicating the minimum and maximum values it supports, so if you truly need to find the min and max for your platform then you'd need to write some code to find them experimentally at runtime, e.g. using an exponential search.