20#ifndef ORES_UTILITY_RFL_TIME_POINT_PARSER_HPP
21#define ORES_UTILITY_RFL_TIME_POINT_PARSER_HPP
26#include "ores.platform/time/datetime.hpp"
28namespace rfl::parsing {
30template <
class ReaderType,
class WriterType,
class ProcessorsType>
31struct Parser<ReaderType, WriterType,
32 std::chrono::system_clock::time_point, ProcessorsType> {
33 using InputVarType =
typename ReaderType::InputVarType;
34 using OutputVarType =
typename WriterType::OutputVarType;
39 static Result<std::chrono::system_clock::time_point> read(
40 const ReaderType& _r,
const InputVarType& _var)
noexcept {
41 const auto str_result = Parser<ReaderType, WriterType,
42 std::string, ProcessorsType>::read(_r, _var);
44 return rfl::Unexpected(Error(str_result.error().what()));
49 }
catch (
const std::exception& e) {
50 return rfl::Unexpected(Error(e.what()));
55 static void write(
const WriterType& _w,
56 const std::chrono::system_clock::time_point& _tp,
57 const P& _parent)
noexcept {
59 Parser<ReaderType, WriterType, std::string, ProcessorsType>::write(
65 template <
class SchemaType>
66 static SchemaType to_schema(
67 std::map<std::string, SchemaType>* _definitions) {
68 return Parser<ReaderType, WriterType,
69 std::string, ProcessorsType>::to_schema(_definitions);
static std::chrono::system_clock::time_point from_iso8601_utc(const std::string &str)
Parses an ISO 8601 UTC string to a time point.
Definition datetime.cpp:45
static std::string to_iso8601_utc(const std::chrono::system_clock::time_point &tp)
Serialises a time point to ISO 8601 UTC string with 'Z' suffix.
Definition datetime.cpp:30