From a98326eb2954ac1e79f5eac28dbeab3ec15e047f Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Sat, 30 Jun 2018 12:43:08 +0200 Subject: 10.1 --- zen/time.h | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'zen/time.h') diff --git a/zen/time.h b/zen/time.h index 723614ef..b06d3d15 100755 --- a/zen/time.h +++ b/zen/time.h @@ -217,12 +217,11 @@ struct PredefinedFormatTag {}; template inline String formatTime(const String2& format, const TimeComp& tc, UserDefinedFormatTag) //format as specified by "std::strftime", returns empty string on failure { - using CharType = typename GetCharType::Type; std::tm ctc = toClibTimeComponents(tc); std::mktime(&ctc); // unfortunately std::strftime() needs all elements of "struct tm" filled, e.g. tm_wday, tm_yday //note: although std::mktime() explicitly expects "local time", calculating weekday and day of year *should* be time-zone and DST independent - CharType buffer[256] = {}; + GetCharTypeT buffer[256] = {}; const size_t charsWritten = strftimeWrap(buffer, 256, strBegin(format), &ctc); return String(buffer, charsWritten); } @@ -231,8 +230,7 @@ String formatTime(const String2& format, const TimeComp& tc, UserDefinedFormatTa template inline String formatTime(FormatType, const TimeComp& tc, PredefinedFormatTag) { - using CharType = typename GetCharType::Type; - return formatTime(GetFormat().format(CharType()), tc, UserDefinedFormatTag()); + return formatTime(GetFormat().format(GetCharTypeT()), tc, UserDefinedFormatTag()); } } @@ -306,13 +304,13 @@ String formatTime(const String2& format, const TimeComp& tc) if (tc == TimeComp()) //failure code from getLocalTime() return String(); - using FormatTag = typename SelectIf< - IsSameType::value || - IsSameType::value || - IsSameType::value || - IsSameType::value || - IsSameType::value || - IsSameType::value, impl::PredefinedFormatTag, impl::UserDefinedFormatTag>::Type; + using FormatTag = std::conditional_t< + std::is_same_v || + std::is_same_v || + std::is_same_v || + std::is_same_v || + std::is_same_v || + std::is_same_v, impl::PredefinedFormatTag, impl::UserDefinedFormatTag>; return impl::formatTime(format, tc, FormatTag()); } @@ -323,8 +321,8 @@ namespace impl template TimeComp parseTime(const String& format, const String2& str, UserDefinedFormatTag) { - using CharType = typename GetCharType::Type; - static_assert(IsSameType::Type>::value, ""); + using CharType = GetCharTypeT; + static_assert(std::is_same_v>); const CharType* itStr = strBegin(str); const CharType* const strLast = itStr + strLength(str); @@ -429,8 +427,7 @@ TimeComp parseTime(const String& format, const String2& str, UserDefinedFormatTa template inline TimeComp parseTime(FormatType, const String& str, PredefinedFormatTag) { - using CharType = typename GetCharType::Type; - return parseTime(GetFormat().format(CharType()), str, UserDefinedFormatTag()); + return parseTime(GetFormat().format(GetCharTypeT()), str, UserDefinedFormatTag()); } } @@ -438,10 +435,10 @@ TimeComp parseTime(FormatType, const String& str, PredefinedFormatTag) template inline TimeComp parseTime(const String& format, const String2& str) { - using FormatTag = typename SelectIf< - IsSameType::value || - IsSameType::value || - IsSameType::value, impl::PredefinedFormatTag, impl::UserDefinedFormatTag>::Type; + using FormatTag = std::conditional_t< + std::is_same_v || + std::is_same_v || + std::is_same_v, impl::PredefinedFormatTag, impl::UserDefinedFormatTag>; return impl::parseTime(format, str, FormatTag()); } -- cgit