glaze icon indicating copy to clipboard operation
glaze copied to clipboard

Add std::chrono support

Open stephenberry opened this issue 1 year ago • 2 comments

stephenberry avatar Jun 24 '24 16:06 stephenberry

I've recently started using glaze (thanks, it's been nice so far) and I currently have some ad-hoc specializations for handling a few basic std::chrono types that need to be serialized in our code.

Seeing this issue I have two questions:

  • Has there been any progress on this / is anyone working on it? (I want to avoid duplicating effort)
  • Would you be interested in a PR even if it only handles a subset of the std::chrono types?

Regarding the latter: serializing durations is easy, but serializing time points is not -- except if we are dealing with a time point derived from a clock with a standardized epoch (like std::chrono::system_clock on C++20 or higher). I'd tend towards only supporting serialization of timepoints with well-defined clocks, rather than ending up in a situation where there's a non-portable default serialization of a time point using some arbitrary epoch.

PeterTh avatar Oct 11 '25 23:10 PeterTh

No one is working this problem at the moment. So, I would be happy to merge in a pull request that implements an initial subset of support for std::chrono. I think your plan of attack makes sense.

I'll just note that whatever support is added should probably support the custom_read and custom_write meta booleans, so that whatever default is supplied can still be overwritten with a custom glz::meta: handling-ambiguous-partial-specialization

stephenberry avatar Oct 13 '25 14:10 stephenberry