What happens when the clock of the computer running python (Windows or Linux)
gets automatically changed and a call time.time()?
I've read that the value of time.time() will be smaller when the clock is changed manually to some value in the past.
解决方案
time.time() docs state:
Return the time in seconds since the epoch as a floating point number.
The particular epoch referred to here is the Unix epoch, which is Midnight, Jan 1st 1970 UTC.
Since it is always based on UTC, it will not be affected by changing the computer's time zone, nor when the computer's time zone enters or exits daylight saving time.
Though the function does rely on the underlying implementation to provide the value, those implementations always return values in terms of UTC - regardless of operating system.
On Windows in particular, it ultimately calls the GetSystemTimeAsFileTime OS function, which returns its value in terms of UTC. It is not affected by time zone selection or by DST changes within the time zone.