2023-03-06 14:42:04 +01:00
|
|
|
// SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
// Copyright CM4all GmbH
|
|
|
|
// author: Max Kellermann <mk@cm4all.com>
|
2018-07-25 08:29:34 +02:00
|
|
|
|
|
|
|
#ifndef TIME_ISO8601_HXX
|
|
|
|
#define TIME_ISO8601_HXX
|
|
|
|
|
|
|
|
#include <chrono>
|
2020-03-13 00:46:28 +01:00
|
|
|
#include <cstddef>
|
2020-07-23 16:24:45 +02:00
|
|
|
#include <utility>
|
2019-05-08 16:24:31 +02:00
|
|
|
|
2018-07-25 08:29:34 +02:00
|
|
|
struct tm;
|
2019-05-08 16:24:31 +02:00
|
|
|
template<size_t CAPACITY> class StringBuffer;
|
2018-07-25 08:29:34 +02:00
|
|
|
|
2021-02-08 14:59:40 +01:00
|
|
|
[[gnu::pure]]
|
2018-07-25 08:29:34 +02:00
|
|
|
StringBuffer<64>
|
|
|
|
FormatISO8601(const struct tm &tm) noexcept;
|
|
|
|
|
2021-02-08 14:59:40 +01:00
|
|
|
[[gnu::pure]]
|
2018-07-25 08:29:34 +02:00
|
|
|
StringBuffer<64>
|
|
|
|
FormatISO8601(std::chrono::system_clock::time_point tp);
|
|
|
|
|
2019-08-19 22:28:14 +02:00
|
|
|
/**
|
|
|
|
* Parse a time stamp in ISO8601 format.
|
|
|
|
*
|
|
|
|
* Throws on error.
|
|
|
|
*
|
|
|
|
* @return a pair consisting of the time point and the specified
|
|
|
|
* precision; e.g. for a date, the second value is "one day"
|
|
|
|
*/
|
|
|
|
std::pair<std::chrono::system_clock::time_point,
|
|
|
|
std::chrono::system_clock::duration>
|
2018-07-25 08:29:34 +02:00
|
|
|
ParseISO8601(const char *s);
|
|
|
|
|
|
|
|
#endif
|