Parser for chrono::time_point#648
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for std::chrono::time_point serialization and deserialization, including a new Parser_time_point.hpp header and comprehensive unit tests. The implementation handles ISO 8601 formatting with microsecond precision. Feedback focuses on restricting the parser to std::chrono::system_clock to ensure compatibility with calendar-time conversions, increasing precision to nanoseconds, and improving input validation to strictly enforce the 'Z' suffix. Additionally, a thread-safety improvement was suggested regarding locale handling during parsing.
steady clock and hr clock causes problems
|
just timezones/docs left. A parser for std::chrono::zoned_time down the line would fix it, perhaps a follow-up PR instead of this one. For the time being I'll just do the timezone conversions :) |
|
Timezone conversion and docs done, implementing a parser for std::chrono::zoned_time next would let users preserve timezone data when reading/writing. I can work on this later next week. I think though this may or may not be a slippery slope of many more std::chrono parsers to come? Not sure whats best for reflect-cpp. Otherwise, this is ready for review :) |
|
@ron0studios looks great. No notes. Should we merge? |
|
@liuzicheng1987 Nope i think things look good from my end - ill work on zoned_time as well some point next week |
Addresses #586.
There are a couple immediate problems that I am not sure how to proceed with.
This forces an ISO 8601 time format conversion, which also needs some logic to convert. This could be slow.
I believe Parser duration uses a simpler struct format, which makes sense for the type:
{"seconds": 1234567, "microseconds": 123456}, but for a time_point a date-time format would make more sense.
Also we could go a step further and use nanosecond precision instead of the microsecond precision shown here.
TODO