Message391218
"platform dependent" was added in 2017 by the commit (bpo-29026):
commit 23557d59b819f57800ddef0b1373acef8e024670
Author: Eric Appelt <eric.appelt@gmail.com>
Date: Thu Feb 16 05:00:45 2017 -0500
bpo-29026: Clarify documentation of time.time (#34)
* bpo-29026: Clarity documentation of time.time
Clarify the documentation of time.time by more
precisely defining what is meant by "seconds since
the epoch" on most platforms. Additionally explain
how gmtime and localtime may be used to extract
calendar components and convert to a more common
date format.
* bpo-29026: Minor improvements for time.time doc
* bpo-29026: Consistency fixes for time.time doc
---
MS-DOS (no longer supported by Python since 2014) uses 1980-01-01 epoch.
The Windows FILETIME type uses 1601-01-01 epoch. Python has convention functions to the Unix 1970-01-01 Epoch:
static __int64 secs_between_epochs = 11644473600; /* Seconds between 1.1.1601 and 1.1.1970 */
static void
FILE_TIME_to_time_t_nsec(FILETIME *in_ptr, time_t *time_out, int* nsec_out)
{
/* XXX endianness. Shouldn't matter, as all Windows implementations are little-endian */
/* Cannot simply cast and dereference in_ptr,
since it might not be aligned properly */
__int64 in;
memcpy(&in, in_ptr, sizeof(in));
*nsec_out = (int)(in % 10000000) * 100; /* FILETIME is in units of 100 nsec. */
*time_out = Py_SAFE_DOWNCAST((in / 10000000) - secs_between_epochs, __int64, time_t);
}
void
_Py_time_t_to_FILE_TIME(time_t time_in, int nsec_in, FILETIME *out_ptr)
{
/* XXX endianness */
__int64 out;
out = time_in + secs_between_epochs;
out = out * 10000000 + nsec_in / 100;
memcpy(out_ptr, &out, sizeof(out));
}
More epochs for more fun:
https://en.wikipedia.org/wiki/Epoch_(computing)#Notable_epoch_dates_in_computing |
|
Date |
User |
Action |
Args |
2021-04-16 15:31:39 | vstinner | set | recipients:
+ vstinner, docs@python, Ofekmeister, p-ganssle |
2021-04-16 15:31:39 | vstinner | set | messageid: <1618587099.25.0.575823848681.issue43869@roundup.psfhosted.org> |
2021-04-16 15:31:39 | vstinner | link | issue43869 messages |
2021-04-16 15:31:39 | vstinner | create | |
|