AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
rfc3339.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++23 standard
3 Copyright (C) 2026 Vincent Lachenal
4
5 This file is part of ANCH Framework.
6
7 ANCH Framework is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 ANCH Framework is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with ANCH Framework. If not, see <https://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include "anch-date-export.hpp"
23
24#include <chrono>
25#include <cstddef>
26#include <string>
27#include <string_view>
28
29#include "date/date.hpp"
30#include "date/dateTime.hpp"
31#include "date/offsetTime.hpp"
32#include "date/time.hpp"
33
34
61
67 enum class Offset {
70
74 };
75
77 constexpr std::size_t DATE_TIME_MAX_SIZE = 35;
78
80 constexpr std::size_t DATE_SIZE = 10;
81
83 constexpr std::size_t TIME_MAX_SIZE = 18;
84
86 constexpr std::size_t FULL_TIME_MAX_SIZE = 24;
87
98 ANCH_DATE_EXPORT std::size_t formatDateTime(const anch::date::DateTime& date, char* output, Offset offset = Offset::UTC) noexcept;
99
108 ANCH_DATE_EXPORT std::string formatDateTime(const anch::date::DateTime& date, Offset offset = Offset::UTC);
109
120 ANCH_DATE_EXPORT anch::date::DateTime parseDateTime(std::string_view text);
121
130 ANCH_DATE_EXPORT std::size_t formatDate(const anch::date::Date& date, char* output) noexcept;
131
139 ANCH_DATE_EXPORT std::string formatDate(const anch::date::Date& date);
140
150 ANCH_DATE_EXPORT anch::date::Date parseDate(std::string_view text);
151
163 ANCH_DATE_EXPORT std::size_t formatTime(const anch::date::Time& time, char* output) noexcept;
164
174 ANCH_DATE_EXPORT std::string formatTime(const anch::date::Time& time);
175
187 ANCH_DATE_EXPORT anch::date::Time parseTime(std::string_view text);
188
197 ANCH_DATE_EXPORT std::size_t formatFullTime(const anch::date::OffsetTime& time, char* output) noexcept;
198
205 ANCH_DATE_EXPORT std::string formatFullTime(const anch::date::OffsetTime& time);
206
215 ANCH_DATE_EXPORT anch::date::OffsetTime parseFullTime(std::string_view text);
216
217} // anch::date::rfc3339
Calendar day (RFC 3339 full-date , JSON schema and OpenAPI date format, XSD xs:date ).
Definition date.hpp:63
Point in time.
Definition dateTime.hpp:89
Time of day with an offset from UTC (RFC 3339 full-time , time format of JSON schema and OpenAPI).
Definition offsetTime.hpp:49
Time of day (RFC 3339 partial-time , SQL TIME , XSD xs:time without time zone).
Definition time.hpp:48
RFC 3339 dates formatting and parsing.
Definition rfc3339.hpp:60
constexpr std::size_t FULL_TIME_MAX_SIZE
Definition rfc3339.hpp:86
constexpr std::size_t TIME_MAX_SIZE
Definition rfc3339.hpp:83
Offset
Offset used to format date-time.
Definition rfc3339.hpp:67
@ UTC
Definition rfc3339.hpp:69
anch::date::Date parseDate(std::string_view text)
std::size_t formatDateTime(const anch::date::DateTime &date, char *output, Offset offset=Offset::UTC) noexcept
constexpr std::size_t DATE_SIZE
Definition rfc3339.hpp:80
anch::date::DateTime parseDateTime(std::string_view text)
std::size_t formatFullTime(const anch::date::OffsetTime &time, char *output) noexcept
std::size_t formatTime(const anch::date::Time &time, char *output) noexcept
std::size_t formatDate(const anch::date::Date &date, char *output) noexcept
anch::date::Time parseTime(std::string_view text)
anch::date::OffsetTime parseFullTime(std::string_view text)
constexpr std::size_t DATE_TIME_MAX_SIZE
Definition rfc3339.hpp:77
Dates namespace.
@ LOCAL
Definition date.hpp:46
@ UTC
Definition date.hpp:44