xentara-utils v1.1
Xentara utilities library
|
std::chrono compatibility More...
Classes | |
class | DecomposedDate |
A date, decomposed into its components. More... | |
class | DecomposedTimePoint |
A time point, decomposed into its components. More... | |
Functions | |
constexpr auto | maxDateLength () -> std::size_t |
Returns the maximum length needed to hold a date string. More... | |
constexpr auto | maxTimeStringSize (int secondsPrecision=9) -> std::size_t |
Returns the maximum length needed to hold a time string. More... | |
constexpr auto | maxDateTimeStringSize (int secondsPrecision=9) -> std::size_t |
Returns the maximum length needed to hold a date and time string. More... | |
template<tools::CharType Char, typename CharTraits = std::char_traits<Char>> | |
auto | toBasicString (std::chrono::system_clock::time_point timePoint, const std::optional< std::chrono::minutes > &utcOffset=std::nullopt) -> string::BasicStaticString< Char, maxDateTimeStringSize(), CharTraits > |
Converts a time point to a string. More... | |
auto | toString (std::chrono::system_clock::time_point timePoint, const std::optional< std::chrono::minutes > &utcOffset=std::nullopt) -> string::StaticString< maxDateTimeStringSize()> |
Converts a time point to a string of type char More... | |
auto | toWString (std::chrono::system_clock::time_point timePoint, const std::optional< std::chrono::minutes > &utcOffset=std::nullopt) -> string::StaticWString< maxDateTimeStringSize()> |
Converts a time point to a string of type wchar_t More... | |
auto | toU8String (std::chrono::system_clock::time_point timePoint, const std::optional< std::chrono::minutes > &utcOffset=std::nullopt) -> string::StaticU8String< maxDateTimeStringSize()> |
Converts a time point to a string of type char8_t More... | |
auto | toU16String (std::chrono::system_clock::time_point timePoint, const std::optional< std::chrono::minutes > &utcOffset=std::nullopt) -> string::StaticU16String< maxDateTimeStringSize()> |
Converts a time point to a string of type char16_t More... | |
auto | toU32String (std::chrono::system_clock::time_point timePoint, const std::optional< std::chrono::minutes > &utcOffset=std::nullopt) -> string::StaticU32String< maxDateTimeStringSize()> |
Converts a number to a string of type char32_t More... | |
template<tools::CharType Char, typename CharTraits = std::char_traits<Char>> | |
auto | toCompactBasicString (std::chrono::system_clock::time_point timePoint, const std::optional< std::chrono::minutes > &utcOffset=std::nullopt) -> string::BasicStaticString< Char, maxDateTimeStringSize(), CharTraits > |
Converts a time point to a string without unecessary seconds or fractions of a second. More... | |
auto | toCompactString (std::chrono::system_clock::time_point timePoint, const std::optional< std::chrono::minutes > &utcOffset=std::nullopt) -> string::StaticString< maxDateTimeStringSize()> |
Converts a time point to a string of type char without unecessary seconds or fractions of a second. More... | |
auto | toCompactWString (std::chrono::system_clock::time_point timePoint, const std::optional< std::chrono::minutes > &utcOffset=std::nullopt) -> string::StaticWString< maxDateTimeStringSize()> |
Converts a time point to a string of type wchar_t without unecessary seconds or fractions of a second. More... | |
auto | toCompactU8String (std::chrono::system_clock::time_point timePoint, const std::optional< std::chrono::minutes > &utcOffset=std::nullopt) -> string::StaticU8String< maxDateTimeStringSize()> |
Converts a time point to a string of type char8_t without unecessary seconds or fractions of a second. More... | |
auto | toCompactU16String (std::chrono::system_clock::time_point timePoint, const std::optional< std::chrono::minutes > &utcOffset=std::nullopt) -> string::StaticU16String< maxDateTimeStringSize()> |
Converts a time point to a string of type char16_t without unecessary seconds or fractions of a second. More... | |
auto | toCompactU32String (std::chrono::system_clock::time_point timePoint, const std::optional< std::chrono::minutes > &utcOffset=std::nullopt) -> string::StaticU32String< maxDateTimeStringSize()> |
Converts a number to a string of type char32_t without unecessary seconds or fractions of a second. More... | |
template<tools::CharType Char, typename CharTraits = std::char_traits<Char>> | |
auto | toIsoBasicString (std::chrono::system_clock::time_point timePoint, const std::optional< std::chrono::minutes > &utcOffset=std::nullopt) -> string::BasicStaticString< Char, maxDateTimeStringSize(), CharTraits > |
Converts a time point to a string in ISO 8601/RFC 3999 format. More... | |
auto | toIsoString (std::chrono::system_clock::time_point timePoint, const std::optional< std::chrono::minutes > &utcOffset=std::nullopt) -> string::StaticString< maxDateTimeStringSize()> |
Converts a time point to a string of type char in ISO 8601/RFC 3999 format. More... | |
auto | toIsoWString (std::chrono::system_clock::time_point timePoint, const std::optional< std::chrono::minutes > &utcOffset=std::nullopt) -> string::StaticWString< maxDateTimeStringSize()> |
Converts a time point to a string of type wchar_t in ISO 8601/RFC 3999 format. More... | |
auto | toIsoU8String (std::chrono::system_clock::time_point timePoint, const std::optional< std::chrono::minutes > &utcOffset=std::nullopt) -> string::StaticU8String< maxDateTimeStringSize()> |
Converts a time point to a string of type char8_t in ISO 8601/RFC 3999 format. More... | |
auto | toIsoU16String (std::chrono::system_clock::time_point timePoint, const std::optional< std::chrono::minutes > &utcOffset=std::nullopt) -> string::StaticU16String< maxDateTimeStringSize()> |
Converts a time point to a string of type char16_t in ISO 8601/RFC 3999 format. More... | |
auto | toIsoU32String (std::chrono::system_clock::time_point timePoint, const std::optional< std::chrono::minutes > &utcOffset=std::nullopt) -> string::StaticU32String< maxDateTimeStringSize()> |
Converts a number to a string of type char32_t in ISO 8601/RFC 3999 format. More... | |
template<typename Rep , typename Period > | |
auto | toTimeSpec (const std::chrono::duration< Rep, Period > &duration) -> eh::Failable< std::timespec > |
Converts a duration to an std::timespec value. More... | |
template<typename Clock , typename Duration > | |
auto | toTimeSpec (const std::chrono::time_point< Clock, Duration > &timePoint) -> eh::Failable< std::timespec > |
Converts a time point to an std::timespec value. More... | |
std::chrono compatibility
This namespace contains date and time facilities.
|
constexpr |
Returns the maximum length needed to hold a date string.
This function can be used to preallocate buffers used to format date strings.
|
constexpr |
Returns the maximum length needed to hold a date and time string.
This function can be used to preallocate buffers used to format time and date strings.
secondsPrecision | The precision for the seconds. If secondsPrecision is negative, then the space needed for a string without seconds is returned. |
|
constexpr |
Returns the maximum length needed to hold a time string.
This function can be used to preallocate buffers used to format time strings.
secondsPrecision | The precision for the seconds. If secondsPrecision is negative, then the space needed for a string without seconds is returned. |
auto xentara::utils::chrono::toBasicString | ( | std::chrono::system_clock::time_point | timePoint, |
const std::optional< std::chrono::minutes > & | utcOffset = std::nullopt |
||
) | -> string::BasicStaticString<Char, maxDateTimeStringSize(), CharTraits> |
Converts a time point to a string.
timePoint | The time point |
utcOffset | The UTC offset to represent the time in, or std::nullopt to use local time. The UTC offset only influences how the time is represented in the constructed object: timePoint must always be a regular UTC time without any offset. If you pass a time of 1 January 2001, 00:00:00.000 UTC and a UTC offset of +1 hours, the time will decomposed to 2001-01-01 01:00:00 UTC+01:00, for example. |
auto xentara::utils::chrono::toCompactBasicString | ( | std::chrono::system_clock::time_point | timePoint, |
const std::optional< std::chrono::minutes > & | utcOffset = std::nullopt |
||
) | -> string::BasicStaticString<Char, maxDateTimeStringSize(), CharTraits> |
Converts a time point to a string without unecessary seconds or fractions of a second.
The returned string only shows as much of seconds and fractions of a second as necessary
timePoint | The time point |
utcOffset | The UTC offset to represent the time in, or std::nullopt to use local time. The UTC offset only influences how the time is represented in the constructed object: timePoint must always be a regular UTC time without any offset. If you pass a time of 1 January 2001, 00:00:00.000 UTC and a UTC offset of +1 hours, the time will decomposed to 2001-01-01 01:00:00 UTC+01:00, for example. |
auto xentara::utils::chrono::toCompactString | ( | std::chrono::system_clock::time_point | timePoint, |
const std::optional< std::chrono::minutes > & | utcOffset = std::nullopt |
||
) | -> string::StaticString<maxDateTimeStringSize()> |
Converts a time point to a string of type char without unecessary seconds or fractions of a second.
The returned string only shows as much of seconds and fractions of a second as necessary
timePoint | The time point |
utcOffset | The UTC offset to represent the time in, or std::nullopt to use local time. The UTC offset only influences how the time is represented in the constructed object: timePoint must always be a regular UTC time without any offset. If you pass a time of 1 January 2001, 00:00:00.000 UTC and a UTC offset of +1 hours, the time will decomposed to 2001-01-01 01:00:00 UTC+01:00, for example. |
auto xentara::utils::chrono::toCompactU16String | ( | std::chrono::system_clock::time_point | timePoint, |
const std::optional< std::chrono::minutes > & | utcOffset = std::nullopt |
||
) | -> string::StaticU16String<maxDateTimeStringSize()> |
Converts a time point to a string of type char16_t without unecessary seconds or fractions of a second.
The returned string only shows as much of seconds and fractions of a second as necessary
timePoint | The time point |
utcOffset | The UTC offset to represent the time in, or std::nullopt to use local time. The UTC offset only influences how the time is represented in the constructed object: timePoint must always be a regular UTC time without any offset. If you pass a time of 1 January 2001, 00:00:00.000 UTC and a UTC offset of +1 hours, the time will decomposed to 2001-01-01 01:00:00 UTC+01:00, for example. |
auto xentara::utils::chrono::toCompactU32String | ( | std::chrono::system_clock::time_point | timePoint, |
const std::optional< std::chrono::minutes > & | utcOffset = std::nullopt |
||
) | -> string::StaticU32String<maxDateTimeStringSize()> |
Converts a number to a string of type char32_t without unecessary seconds or fractions of a second.
The returned string only shows as much of seconds and fractions of a second as necessary
timePoint | The time point |
utcOffset | The UTC offset to represent the time in, or std::nullopt to use local time. The UTC offset only influences how the time is represented in the constructed object: timePoint must always be a regular UTC time without any offset. If you pass a time of 1 January 2001, 00:00:00.000 UTC and a UTC offset of +1 hours, the time will decomposed to 2001-01-01 01:00:00 UTC+01:00, for example. |
auto xentara::utils::chrono::toCompactU8String | ( | std::chrono::system_clock::time_point | timePoint, |
const std::optional< std::chrono::minutes > & | utcOffset = std::nullopt |
||
) | -> string::StaticU8String<maxDateTimeStringSize()> |
Converts a time point to a string of type char8_t without unecessary seconds or fractions of a second.
The returned string only shows as much of seconds and fractions of a second as necessary
timePoint | The time point |
utcOffset | The UTC offset to represent the time in, or std::nullopt to use local time. The UTC offset only influences how the time is represented in the constructed object: timePoint must always be a regular UTC time without any offset. If you pass a time of 1 January 2001, 00:00:00.000 UTC and a UTC offset of +1 hours, the time will decomposed to 2001-01-01 01:00:00 UTC+01:00, for example. |
auto xentara::utils::chrono::toCompactWString | ( | std::chrono::system_clock::time_point | timePoint, |
const std::optional< std::chrono::minutes > & | utcOffset = std::nullopt |
||
) | -> string::StaticWString<maxDateTimeStringSize()> |
Converts a time point to a string of type wchar_t without unecessary seconds or fractions of a second.
The returned string only shows as much of seconds and fractions of a second as necessary
timePoint | The time point |
utcOffset | The UTC offset to represent the time in, or std::nullopt to use local time. The UTC offset only influences how the time is represented in the constructed object: timePoint must always be a regular UTC time without any offset. If you pass a time of 1 January 2001, 00:00:00.000 UTC and a UTC offset of +1 hours, the time will decomposed to 2001-01-01 01:00:00 UTC+01:00, for example. |
auto xentara::utils::chrono::toIsoBasicString | ( | std::chrono::system_clock::time_point | timePoint, |
const std::optional< std::chrono::minutes > & | utcOffset = std::nullopt |
||
) | -> string::BasicStaticString<Char, maxDateTimeStringSize(), CharTraits> |
Converts a time point to a string in ISO 8601/RFC 3999 format.
The returned string has the format YYYY-MM-DDThh:mm:ss.zzzzzzzzz±HH:MM. For a utcOffset of 0, ±HH:MM is replaced with the character “Z”.
timePoint | The time point |
utcOffset | The UTC offset to represent the time in, or std::nullopt to use local time. The UTC offset only influences how the time is represented in the constructed object: timePoint must always be a regular UTC time without any offset. If you pass a time of 1 January 2001, 00:00:00.000 UTC and a UTC offset of +1 hours, the time will decomposed to 2001-01-01 01:00:00 UTC+01:00, for example. |
auto xentara::utils::chrono::toIsoString | ( | std::chrono::system_clock::time_point | timePoint, |
const std::optional< std::chrono::minutes > & | utcOffset = std::nullopt |
||
) | -> string::StaticString<maxDateTimeStringSize()> |
Converts a time point to a string of type char in ISO 8601/RFC 3999 format.
The returned string has the format YYYY-MM-DDThh:mm:ss.zzzzzzzzz±HH:MM. For a utcOffset of 0, ±HH:MM is replaced with the character “Z”.
timePoint | The time point |
utcOffset | The UTC offset to represent the time in, or std::nullopt to use local time. The UTC offset only influences how the time is represented in the constructed object: timePoint must always be a regular UTC time without any offset. If you pass a time of 1 January 2001, 00:00:00.000 UTC and a UTC offset of +1 hours, the time will decomposed to 2001-01-01 01:00:00 UTC+01:00, for example. |
auto xentara::utils::chrono::toIsoU16String | ( | std::chrono::system_clock::time_point | timePoint, |
const std::optional< std::chrono::minutes > & | utcOffset = std::nullopt |
||
) | -> string::StaticU16String<maxDateTimeStringSize()> |
Converts a time point to a string of type char16_t in ISO 8601/RFC 3999 format.
The returned string has the format YYYY-MM-DDThh:mm:ss.zzzzzzzzz±HH:MM. For a utcOffset of 0, ±HH:MM is replaced with the character “Z”.
timePoint | The time point |
utcOffset | The UTC offset to represent the time in, or std::nullopt to use local time. The UTC offset only influences how the time is represented in the constructed object: timePoint must always be a regular UTC time without any offset. If you pass a time of 1 January 2001, 00:00:00.000 UTC and a UTC offset of +1 hours, the time will decomposed to 2001-01-01 01:00:00 UTC+01:00, for example. |
auto xentara::utils::chrono::toIsoU32String | ( | std::chrono::system_clock::time_point | timePoint, |
const std::optional< std::chrono::minutes > & | utcOffset = std::nullopt |
||
) | -> string::StaticU32String<maxDateTimeStringSize()> |
Converts a number to a string of type char32_t in ISO 8601/RFC 3999 format.
The returned string has the format YYYY-MM-DDThh:mm:ss.zzzzzzzzz±HH:MM. For a utcOffset of 0, ±HH:MM is replaced with the character “Z”.
timePoint | The time point |
utcOffset | The UTC offset to represent the time in, or std::nullopt to use local time. The UTC offset only influences how the time is represented in the constructed object: timePoint must always be a regular UTC time without any offset. If you pass a time of 1 January 2001, 00:00:00.000 UTC and a UTC offset of +1 hours, the time will decomposed to 2001-01-01 01:00:00 UTC+01:00, for example. |
auto xentara::utils::chrono::toIsoU8String | ( | std::chrono::system_clock::time_point | timePoint, |
const std::optional< std::chrono::minutes > & | utcOffset = std::nullopt |
||
) | -> string::StaticU8String<maxDateTimeStringSize()> |
Converts a time point to a string of type char8_t in ISO 8601/RFC 3999 format.
The returned string has the format YYYY-MM-DDThh:mm:ss.zzzzzzzzz±HH:MM. For a utcOffset of 0, ±HH:MM is replaced with the character “Z”.
timePoint | The time point |
utcOffset | The UTC offset to represent the time in, or std::nullopt to use local time. The UTC offset only influences how the time is represented in the constructed object: timePoint must always be a regular UTC time without any offset. If you pass a time of 1 January 2001, 00:00:00.000 UTC and a UTC offset of +1 hours, the time will decomposed to 2001-01-01 01:00:00 UTC+01:00, for example. |
auto xentara::utils::chrono::toIsoWString | ( | std::chrono::system_clock::time_point | timePoint, |
const std::optional< std::chrono::minutes > & | utcOffset = std::nullopt |
||
) | -> string::StaticWString<maxDateTimeStringSize()> |
Converts a time point to a string of type wchar_t in ISO 8601/RFC 3999 format.
The returned string has the format YYYY-MM-DDThh:mm:ss.zzzzzzzzz±HH:MM. For a utcOffset of 0, ±HH:MM is replaced with the character “Z”.
timePoint | The time point |
utcOffset | The UTC offset to represent the time in, or std::nullopt to use local time. The UTC offset only influences how the time is represented in the constructed object: timePoint must always be a regular UTC time without any offset. If you pass a time of 1 January 2001, 00:00:00.000 UTC and a UTC offset of +1 hours, the time will decomposed to 2001-01-01 01:00:00 UTC+01:00, for example. |
auto xentara::utils::chrono::toString | ( | std::chrono::system_clock::time_point | timePoint, |
const std::optional< std::chrono::minutes > & | utcOffset = std::nullopt |
||
) | -> string::StaticString<maxDateTimeStringSize()> |
Converts a time point to a string of type char
timePoint | The time point |
utcOffset | The UTC offset to represent the time in, or std::nullopt to use local time. The UTC offset only influences how the time is represented in the constructed object: timePoint must always be a regular UTC time without any offset. If you pass a time of 1 January 2001, 00:00:00.000 UTC and a UTC offset of +1 hours, the time will decomposed to 2001-01-01 01:00:00 UTC+01:00, for example. |
auto xentara::utils::chrono::toTimeSpec | ( | const std::chrono::duration< Rep, Period > & | duration | ) | -> eh::Failable<std::timespec> |
Converts a duration to an std::timespec value.
auto xentara::utils::chrono::toTimeSpec | ( | const std::chrono::time_point< Clock, Duration > & | timePoint | ) | -> eh::Failable<std::timespec> |
Converts a time point to an std::timespec value.
auto xentara::utils::chrono::toU16String | ( | std::chrono::system_clock::time_point | timePoint, |
const std::optional< std::chrono::minutes > & | utcOffset = std::nullopt |
||
) | -> string::StaticU16String<maxDateTimeStringSize()> |
Converts a time point to a string of type char16_t
timePoint | The time point |
utcOffset | The UTC offset to represent the time in, or std::nullopt to use local time. The UTC offset only influences how the time is represented in the constructed object: timePoint must always be a regular UTC time without any offset. If you pass a time of 1 January 2001, 00:00:00.000 UTC and a UTC offset of +1 hours, the time will decomposed to 2001-01-01 01:00:00 UTC+01:00, for example. |
auto xentara::utils::chrono::toU32String | ( | std::chrono::system_clock::time_point | timePoint, |
const std::optional< std::chrono::minutes > & | utcOffset = std::nullopt |
||
) | -> string::StaticU32String<maxDateTimeStringSize()> |
Converts a number to a string of type char32_t
timePoint | The time point |
utcOffset | The UTC offset to represent the time in, or std::nullopt to use local time. The UTC offset only influences how the time is represented in the constructed object: timePoint must always be a regular UTC time without any offset. If you pass a time of 1 January 2001, 00:00:00.000 UTC and a UTC offset of +1 hours, the time will decomposed to 2001-01-01 01:00:00 UTC+01:00, for example. |
auto xentara::utils::chrono::toU8String | ( | std::chrono::system_clock::time_point | timePoint, |
const std::optional< std::chrono::minutes > & | utcOffset = std::nullopt |
||
) | -> string::StaticU8String<maxDateTimeStringSize()> |
Converts a time point to a string of type char8_t
timePoint | The time point |
utcOffset | The UTC offset to represent the time in, or std::nullopt to use local time. The UTC offset only influences how the time is represented in the constructed object: timePoint must always be a regular UTC time without any offset. If you pass a time of 1 January 2001, 00:00:00.000 UTC and a UTC offset of +1 hours, the time will decomposed to 2001-01-01 01:00:00 UTC+01:00, for example. |
auto xentara::utils::chrono::toWString | ( | std::chrono::system_clock::time_point | timePoint, |
const std::optional< std::chrono::minutes > & | utcOffset = std::nullopt |
||
) | -> string::StaticWString<maxDateTimeStringSize()> |
Converts a time point to a string of type wchar_t
timePoint | The time point |
utcOffset | The UTC offset to represent the time in, or std::nullopt to use local time. The UTC offset only influences how the time is represented in the constructed object: timePoint must always be a regular UTC time without any offset. If you pass a time of 1 January 2001, 00:00:00.000 UTC and a UTC offset of +1 hours, the time will decomposed to 2001-01-01 01:00:00 UTC+01:00, for example. |