ORE Studio 0.0.4
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | List of all members
Reflector< std::chrono::system_clock::time_point > Struct Reference

Custom reflector for std::chrono::system_clock::time_point. More...

#include <reflectors.hpp>

Collaboration diagram for Reflector< std::chrono::system_clock::time_point >:
Collaboration graph

Public Types

using ReflType = std::string
 

Static Public Member Functions

static std::chrono::system_clock::time_point to (const ReflType &str)
 Parses a string into a time_point.
 
static ReflType from (const std::chrono::system_clock::time_point &v)
 Formats a time_point into a string.
 

Detailed Description

Custom reflector for std::chrono::system_clock::time_point.

Serializes to and from an ISO 8601 compliant UTC string. This is the idiomatic C++23 approach, using std::format and std::chrono::parse for type-safe and portable operations.

Serialized format: "YYYY-MM-DD HH:MM:SS" (assumed to be UTC) Example: "2023-10-27 14:45:30"

Member Function Documentation

◆ to()

static std::chrono::system_clock::time_point to ( const ReflType &  str)
static

Parses a string into a time_point.

Uses std::chrono::from_stream (C++20) to safely parse the string format into a std::chrono::sys_timepoint.

Parameters
strThe string to parse.
Returns
A system_clock::time_point representing the parsed time.
Exceptions
std::runtime_errorif the string cannot be parsed.

◆ from()

static ReflType from ( const std::chrono::system_clock::time_point &  v)
static

Formats a time_point into a string.

Uses std::format (C++23) to create a clean, unambiguous UTC string representation. This avoids all C-style time functions.

Parameters
vThe time_point to format.
Returns
A string representation of the time_point.