Invalid last_modified value on a timezone other than UTC
Hello,
We're using kinto with a database using the Europe/Paris timezone, and we've noticed that the bump_timestamp function calculates a value in the future for the last_modified property. The cause is that the timezone is not taken into account in the as_epoch function. An erroneous timestamp is obtained when the result of the as_epoch function is passed as a parameter to the from_epoch function.
Example :
kinto=# SELECT clock_timestamp(),
clock_timestamp()::TIMESTAMP as timestamp,
from_epoch(as_epoch(clock_timestamp()::TIMESTAMP)) as "timestamp 1 conversion",
from_epoch(as_epoch(from_epoch(as_epoch(clock_timestamp()::TIMESTAMP)))) as "timestamp 2 conversions";
clock_timestamp | timestamp | timestamp 1 conversion | timestamp 2 conversions
-------------------------------+----------------------------+------------------------+-------------------------
2024-06-14 18:53:38.949726+02 | 2024-06-14 18:53:38.949726 | 2024-06-14 20:53:38.95 | 2024-06-14 22:53:38.95
(1 row)
Best regards.
That's probably true indeed.
Are you stuck with the Paris timezone? Can't you do ALTER DATABASE dbname SET TIMEZONE TO UTC;?
Because I don't think we ever supported any other timezone than UTC. We stated in the docs:
https://github.com/Kinto/kinto/blob/5ef3cae12c38cb0441b879b9e2d11707ffb7cc89/docs/configuration/production.rst#database-setup
And that's why we have this check:
https://github.com/Kinto/kinto/blob/5ef3cae12c38cb0441b879b9e2d11707ffb7cc89/kinto/core/storage/postgresql/init.py#L108-L111