Fix time_point to string conversion for large and negative values #37
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes two issues:
time_points which were more than 32bits of seconds from the epoch would wrap due to the silent integer narrowing that happens in
uint32_t time_point::sec_since_epoch() const
as a result those time points would translate to the wrong ISO string.negative time_points are representable due to being composed of the
fc::microsecond
type which can store negative values. However, these have no representable ISO string so they now degrade to a duration in terms of seconds with 3-digits of precision for millisecond output. Effectively providing the same base unit as the ISO string (seconds) and the extra resolution.Note: it is probably worthwhile to consider if changing
::sec_since_epoch() const
and removing the express-ability of negative points in time is worthwhile formaster
. This is being made against a patch release of a downstream product so, it should not make breaking changes to the data types.