Records stamped with the Unix epoch cannot be loaded. A DateTime field in timestamp format refuses the number 0, although 0 is a perfectly good timestamp: midnight on 1 January 1970. Devices that have not synced their cl…
Records stamped with the Unix epoch cannot be loaded. A DateTime field in timestamp format refuses the number 0, although 0 is a perfectly good timestamp: midnight on 1 January 1970. Devices that have not synced their clock yet report exactly that, and their first upload is rejected.
from marshmallow import fields
fields.DateTime(format="timestamp").deserialize(0)
fields.DateTime(format="timestamp_ms").deserialize(0)
Both return datetime.datetime(1970, 1, 1, 0, 0).
Both raise ValidationError: Not a valid datetime.
"0" is already accepted, and so is the number 1.0 in the iso and rfc formats.Adapted from marshmallow-code/marshmallow (MIT).
Visible test command
pytest testsThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
timestamp-zero-rejected
Changes under src/ are evaluated.