-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix formatting of tendermint::Time (#775)
The `Time` datatype needs to be formatted the same way as Go's `time.RFC3339Nano` format, ie. a RFC3339 date-time with left-padded nanoseconds digits without trailing zeros and no trailing dot. This is taken care of by the `to_rfc339_nanos` function in the `tendermint_proto::serializers::timestamp` module. Prior to this commit, this function would incorrectly trim the leading zeros of the nanoseconds digits, which would break the `Time` -> String -> `Time` roundtrip. For example, the date "2021-01-07T17:52:04.034475Z" was serialized as "2021-01-07T17:52:04.34475Z", which then decodes to "2021-01-07T17:52:04.344750Z", shifting the leading zero to the end. This commit fixes `to_rfc339_nanos` function by using `chrono`'s formatting facilities to preserve the precision of the nanoseconds, and then manually trim the trailing zeros and dot.
- Loading branch information
Showing
3 changed files
with
122 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters