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

Timestamp from chrono DateTime doesn't follow spec for pre-UNIX epoch dates #95

Open
neoeinstein opened this issue Mar 6, 2023 · 1 comment

Comments

@neoeinstein
Copy link
Contributor

neoeinstein commented Mar 6, 2023

The contract for a timestamp requires that a timestamp with a negative seconds component must have a negative nanos component. As currently implemented, the nanos component will always be positive when converting from a chrono DateTime. This may cause issues with downstream consumers who expect that the nanos field will follow the behavior defined in the documentation and require a timestamp from before 1970.

For reference on how to correct this, see the implementation of From<SystemTime> in prost-types. (It would also be nice if pbjson-types included a From<SystemTime> implementation as well.)

@benluelo
Copy link

benluelo commented Jun 9, 2024

According to the spec, the nanos field is to always be positive:

Non-negative fractions of a second at nanosecond resolution. Negative second values with fractions must still have non-negative nanos values that count forward in time. Must be from 0 to 999,999,999 inclusive.

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

No branches or pull requests

2 participants