mpd/src/time/ISO8601.hxx

36 lines
768 B
C++
Raw Normal View History

// 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>
#include <cstddef>
2020-07-23 16:24:45 +02:00
#include <utility>
2018-07-25 08:29:34 +02:00
struct tm;
template<size_t CAPACITY> class StringBuffer;
2018-07-25 08:29:34 +02:00
[[gnu::pure]]
2018-07-25 08:29:34 +02:00
StringBuffer<64>
FormatISO8601(const struct tm &tm) noexcept;
[[gnu::pure]]
2018-07-25 08:29:34 +02:00
StringBuffer<64>
FormatISO8601(std::chrono::system_clock::time_point tp);
/**
* 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