Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid last_modified value on a timezone other than UTC #3419

Closed
slafon51 opened this issue Jun 14, 2024 · 1 comment
Closed

Invalid last_modified value on a timezone other than UTC #3419

slafon51 opened this issue Jun 14, 2024 · 1 comment

Comments

@slafon51
Copy link

slafon51 commented Jun 14, 2024

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.

@slafon51 slafon51 changed the title Timezone not taken into account in the as_epoch method Timestamp calculated invalid on a timezone other than UTC Jun 14, 2024
@slafon51 slafon51 changed the title Timestamp calculated invalid on a timezone other than UTC Invalid last_modified value on a timezone other than UTC Jun 17, 2024
@leplatrem
Copy link
Contributor

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:

if timezone != "UTC": # pragma: no cover
msg = f"Database timezone is not UTC ({timezone})"
warnings.warn(msg)
logger.warning(msg)

@slafon51 slafon51 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants