Skip to content

Add serialization for std::chrono::system_clock::time_point #586

@cacharle

Description

@cacharle

I currently have this snippet to all std::chrono::system_clock::time_point to be (de)serialized. I think it would be nice to have something to convert this useful type.

namespace rfl
{

template <>
struct Reflector<std::chrono::system_clock::time_point> {
    using ReflType = std::string;
    static std::chrono::system_clock::time_point to(const ReflType &s)
    {
        return intellis::timePointFromIso8601(s);
    }
    static ReflType from(const std::chrono::system_clock::time_point &tp)
    {
        return intellis::timePointToIso8601<std::chrono::microseconds>(tp);
    }
};

I know that rfl::Timestamp exists but it is limited to seconds which is a deal breaker in my use case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions