POV-Ray / povray

The Persistence of Vision Raytracer: http://www.povray.org/
GNU Affero General Public License v3.0
1.35k stars 282 forks source link

Current implementation of `datetime` is not fully portable. #435

Open c-lipka opened 3 years ago

c-lipka commented 3 years ago

The current implementation of datetime in all branches (v3.7, v3.8 and v4.0) relies on std::time_t representing time as a genuine POSIX timestamp, i.e. seconds since 1970-01-01 00:00 UTC minus leap seconds (or, more formally, days since 1970-01-01 00:00 UTC × 86,400 + seconds since 00:00 UTC),

Although this is typical, and even required for strict POSIX compliance, it is not guaranteed by the C++ standard, and even some POSIXoid systems do exist that do not conform, e.g. systems using a clock based on TAI rather than UTC, with std::time_t representing time as seconds since 1970-01-01 00:00 UTC including leap seconds: On such systems, our current solution would currently be off by ca. 30 seconds.

The C++ standard does not even guarantee a unit duration of 1 second, nor that a numeric value of 0 corresponds to 1970-01-01 00:00 (UTC, local, or otherwise).