HomeSoftware Heritage

postgresql: Fix one-by-one error in db_to_date on negative dates
fb1b3a066ff0Unpublished

Unpublished Commit · Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.

Description

postgresql: Fix one-by-one error in db_to_date on negative dates

Using int() on date.timestamp() rounded it up (toward zero),
but the semantics of model.Timestamp is that the actual time is
ts.seconds + ts.microseconds/1000000, so all negative dates were
shifted one second up.

In particular, this causes dates from
1969-12-31T23:59:59.000001 to 1969-12-31T23:59:59.999999
(inclusive) to smash into dates from
1970-01-01T00:00:00.000001 to 1970-01-01T00:00:00.999999,
which is how I discovered the issue.

Details

Provenance
vlorentzAuthored on Dec 9 2021, 4:25 PM
vlorentzPushed on Dec 13 2021, 12:54 PM
Parents
R65:34ca67e21f68: postgresql: Add tests for db_to_date.
Branches
Unknown
Tags
Unknown
References
tag: phabricator/diff/24748, tag: phabricator/base/24796, tag: phabricator/base/24767, tag: phabricator/base/24749

Event Timeline