From b301929ca468c1dd426301b79c6432289ae691b5 Mon Sep 17 00:00:00 2001 From: offa Date: Wed, 12 Mar 2025 20:35:20 +0100 Subject: [PATCH] Update date to 32ecb2ad24699963f6c58d74d74bcd8bf7e830a9 and apply patch The date library is broken on GCC / Clang on this commit, thus PR866 (https://github.com/HowardHinnant/date/pull/866) is applied. --- 3rd-party/date/date.h | 137 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 124 insertions(+), 13 deletions(-) diff --git a/3rd-party/date/date.h b/3rd-party/date/date.h index beb627e..5ca2ff3 100644 --- a/3rd-party/date/date.h +++ b/3rd-party/date/date.h @@ -963,8 +963,8 @@ operator<<(std::basic_ostream& os, const year_month_weekday_last& inline namespace literals { -CONSTCD11 date::day operator "" _d(unsigned long long d) NOEXCEPT; -CONSTCD11 date::year operator "" _y(unsigned long long y) NOEXCEPT; +CONSTCD11 date::day operator ""_d(unsigned long long d) NOEXCEPT; +CONSTCD11 date::year operator ""_y(unsigned long long y) NOEXCEPT; } // inline namespace literals #endif // !defined(_MSC_VER) || (_MSC_VER >= 1900) @@ -1972,7 +1972,7 @@ inline namespace literals CONSTCD11 inline date::day -operator "" _d(unsigned long long d) NOEXCEPT +operator ""_d(unsigned long long d) NOEXCEPT { return date::day{static_cast(d)}; } @@ -1980,7 +1980,7 @@ operator "" _d(unsigned long long d) NOEXCEPT CONSTCD11 inline date::year -operator "" _y(unsigned long long y) NOEXCEPT +operator ""_y(unsigned long long y) NOEXCEPT { return date::year(static_cast(y)); } @@ -6784,7 +6784,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, checked_set(m, static_cast(i % 12 + 1), not_a_month, is); ws(is); int td = not_a_day; - read(is, rs{td, 1, 2}); + read(is, ru{td, 1, 2}); checked_set(d, td, not_a_day, is); ws(is); using dfs = detail::decimal_format_seconds; @@ -6800,7 +6800,9 @@ from_stream(std::basic_istream& is, const CharT* fmt, not_a_second, is); ws(is); int tY = not_a_year; - read(is, rs{tY, 1, 4u}); + // No need for `rs` here, negative years can't parse + // with "%c" since `width` is hardcoded to 4 + read(is, ru{tY, 1, 4u}); checked_set(Y, tY, not_a_year, is); #endif } @@ -6834,7 +6836,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, int tm = not_a_month; int td = not_a_day; read(is, ru{tm, 1, 2}, CharT{'/'}, ru{td, 1, 2}, CharT{'/'}, - rs{ty, 1, 2}); + ru{ty, 1, 2}); checked_set(y, ty, not_a_2digit_year, is); checked_set(m, tm, not_a_month, is); checked_set(d, td, not_a_day, is); @@ -6930,7 +6932,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, int ty = not_a_2digit_year; read(is, ru{tn, 1, 2}, CharT{'\0'}, CharT{'/'}, CharT{'\0'}, ru{td, 1, 2}, CharT{'\0'}, CharT{'/'}, CharT{'\0'}, - rs{ty, 1, 2}); + ru{ty, 1, 2}); checked_set(y, ty, not_a_2digit_year, is); checked_set(m, tn, not_a_month, is); checked_set(d, td, not_a_day, is); @@ -6978,7 +6980,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, #endif { int td = not_a_day; - read(is, rs{td, 1, width == -1 ? 2u : static_cast(width)}); + read(is, ru{td, 1, width == -1 ? 2u : static_cast(width)}); checked_set(d, td, not_a_day, is); } #if !ONLY_C_LOCALE @@ -7042,7 +7044,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, { int tI = not_a_hour_12_value; // reads in an hour into I, but most be in [1, 12] - read(is, rs{tI, 1, width == -1 ? 2u : static_cast(width)}); + read(is, ru{tI, 1, width == -1 ? 2u : static_cast(width)}); if (!(1 <= tI && tI <= 12)) is.setstate(ios::failbit); checked_set(I, tI, not_a_hour_12_value, is); @@ -7116,7 +7118,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, #endif { int tn = not_a_month; - read(is, rs{tn, 1, width == -1 ? 2u : static_cast(width)}); + read(is, ru{tn, 1, width == -1 ? 2u : static_cast(width)}); checked_set(m, tn, not_a_month, is); } #if !ONLY_C_LOCALE @@ -7536,7 +7538,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, } if (modified == CharT{}) { - read(is, rs{tH, 2, 2}); + read(is, ru{tH, 2, 2}); if (!is.fail()) toff = hours{std::abs(tH)}; if (is.good()) @@ -7556,7 +7558,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, } else { - read(is, rs{tH, 1, 2}); + read(is, ru{tH, 1, 2}); if (!is.fail()) toff = hours{std::abs(tH)}; if (is.good()) @@ -8117,6 +8119,8 @@ struct parse_manip #endif // HAS_STRING_VIEW }; +#ifdef _MSC_VER + template std::basic_istream& operator>>(std::basic_istream& is, @@ -8220,6 +8224,113 @@ parse(const CharT* format, Parsable& tp, return {format, tp, &abbrev, &offset}; } +#else // !defined _MSC_VER + +template +std::basic_istream& +operator>>(std::basic_istream& is, + const parse_manip& x) +{ + return date::from_stream(is, x.format_.c_str(), x.tp_, x.abbrev_, x.offset_); +} + +template +inline +auto +parse(const std::basic_string& format, Parsable& tp) + -> decltype(date::from_stream(std::declval&>(), + format.c_str(), tp), + parse_manip{format, tp}) +{ + return {format, tp}; +} + +template +inline +auto +parse(const std::basic_string& format, Parsable& tp, + std::basic_string& abbrev) + -> decltype(date::from_stream(std::declval&>(), + format.c_str(), tp, &abbrev), + parse_manip{format, tp, &abbrev}) +{ + return {format, tp, &abbrev}; +} + +template +inline +auto +parse(const std::basic_string& format, Parsable& tp, + std::chrono::minutes& offset) + -> decltype(date::from_stream(std::declval&>(), + format.c_str(), tp, + std::declval*>(), + &offset), + parse_manip{format, tp, nullptr, &offset}) +{ + return {format, tp, nullptr, &offset}; +} + +template +inline +auto +parse(const std::basic_string& format, Parsable& tp, + std::basic_string& abbrev, std::chrono::minutes& offset) + -> decltype(date::from_stream(std::declval&>(), + format.c_str(), tp, &abbrev, &offset), + parse_manip{format, tp, &abbrev, &offset}) +{ + return {format, tp, &abbrev, &offset}; +} + +// const CharT* formats + +template +inline +auto +parse(const CharT* format, Parsable& tp) + -> decltype(date::from_stream(std::declval&>(), format, tp), + parse_manip{format, tp}) +{ + return {format, tp}; +} + +template +inline +auto +parse(const CharT* format, Parsable& tp, std::basic_string& abbrev) + -> decltype(date::from_stream(std::declval&>(), format, + tp, &abbrev), + parse_manip{format, tp, &abbrev}) +{ + return {format, tp, &abbrev}; +} + +template +inline +auto +parse(const CharT* format, Parsable& tp, std::chrono::minutes& offset) + -> decltype(date::from_stream(std::declval&>(), format, + tp, std::declval*>(), &offset), + parse_manip{format, tp, nullptr, &offset}) +{ + return {format, tp, nullptr, &offset}; +} + +template +inline +auto +parse(const CharT* format, Parsable& tp, + std::basic_string& abbrev, std::chrono::minutes& offset) + -> decltype(date::from_stream(std::declval&>(), format, + tp, &abbrev, &offset), + parse_manip{format, tp, &abbrev, &offset}) +{ + return {format, tp, &abbrev, &offset}; +} + +#endif // !defined _MSC_VER + // duration streaming template