date: Implement custom datatime formatter, move away from chrono's strftime #7255
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.
Chrono's strftime Format Deviations from GNU's
Chrono's strftime implementation differs from GNU date, and it is unlikely that Chrono will modify its format specifiers to align with GNU's behavior. This PR introduces custom datetime formatting moving away from Chrono's strftime. This fixes some of the below issues.
"%+" : not a valid specifier in GNU.
For "%+" Chorno displays ISO 8601 / RFC 3339 date & time format. Whereas GNU did not have this specifier.
ex:
GNU
Chrono:
"%q": Not supported in Chrono.
GNU date displays quarter of year (1..4). But, this specifier is not supported in chrono.
ex:
GNU:
Chrono:
"%:::z": Chrono Displays less precise timezone offsets.
For "%:::z" specifier GNU displays offset with minutes when required. Chrono always omits minutes from the offset.
ex:
GNU:
Chrono:
Invalid Specifiers:
Chrono throws an error if the format string contains an unsupported specifier.
ex:
GNU:
Chrono:
Padding & Text Case Modifiers:
Chrono does not support formatting options for text outputs such as month names, weekdays etc. Chrono does not support below options
ex:
GNU:
Chrono:
And for the below issues, we are currently using workarounds.
%Z: Does not print the timezone abbreviation.
%N: Not supported; Chrono uses %f instead.
%#z: Displays the timezone offset differently than GNU.