Skip to content

Commit

Permalink
Merge pull request #267 from offa/266-update_date
Browse files Browse the repository at this point in the history
Update date v3.0.2
  • Loading branch information
offa authored Oct 14, 2024
2 parents 96fbb33 + 27b46ab commit aafcaf6
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions 3rd-party/date/date.h
Original file line number Diff line number Diff line change
Expand Up @@ -4228,7 +4228,7 @@ inline
std::basic_ostream<CharT, Traits>&
operator<<(std::basic_ostream<CharT, Traits>& os, const local_time<Duration>& ut)
{
return (os << sys_time<Duration>{ut.time_since_epoch()});
return (date::operator<<(os, sys_time<Duration>{ut.time_since_epoch()}));
}

namespace detail
Expand Down Expand Up @@ -6351,7 +6351,10 @@ read_signed(std::basic_istream<CharT, Traits>& is, unsigned m = 1, unsigned M =
if (('0' <= c && c <= '9') || c == '-' || c == '+')
{
if (c == '-' || c == '+')
{
(void)is.get();
--M;
}
auto x = static_cast<int>(read_unsigned(is, std::max(m, 1u), M));
if (!is.fail())
{
Expand Down Expand Up @@ -6524,7 +6527,14 @@ read(std::basic_istream<CharT, Traits>& is, int a0, Args&& ...args)
*e++ = static_cast<CharT>(CharT(u % 10) + CharT{'0'});
u /= 10;
} while (u > 0);
#if defined(__GNUC__) && __GNUC__ >= 11
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
std::reverse(buf, e);
#if defined(__GNUC__) && __GNUC__ >= 11
#pragma GCC diagnostic pop
#endif
for (auto p = buf; p != e && is.rdstate() == std::ios::goodbit; ++p)
read(is, *p);
}
Expand Down Expand Up @@ -6590,7 +6600,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,

CONSTDATA int not_a_year = numeric_limits<short>::min();
CONSTDATA int not_a_2digit_year = 100;
CONSTDATA int not_a_century = not_a_year / 100;
CONSTDATA int not_a_century = numeric_limits<int>::min();
CONSTDATA int not_a_month = 0;
CONSTDATA int not_a_day = 0;
CONSTDATA int not_a_hour = numeric_limits<int>::min();
Expand Down Expand Up @@ -7517,7 +7527,12 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
{
auto c = static_cast<char>(Traits::to_char_type(ic));
if (c == '-')
{
neg = true;
(void)is.get();
}
else if (c == '+')
(void)is.get();
}
if (modified == CharT{})
{
Expand Down Expand Up @@ -7733,9 +7748,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
year_month_day ymd_trial = sys_days(year{Y}/January/Sunday[1]) +
weeks{U-1} +
(weekday{static_cast<unsigned>(wd)} - Sunday);
if (Y == not_a_year)
Y = static_cast<int>(ymd_trial.year());
else if (year{Y} != ymd_trial.year())
if (year{Y} != ymd_trial.year())
goto broken;
if (m == not_a_month)
m = static_cast<int>(static_cast<unsigned>(ymd_trial.month()));
Expand All @@ -7752,9 +7765,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
year_month_day ymd_trial = sys_days(year{Y}/January/Monday[1]) +
weeks{W-1} +
(weekday{static_cast<unsigned>(wd)} - Monday);
if (Y == not_a_year)
Y = static_cast<int>(ymd_trial.year());
else if (year{Y} != ymd_trial.year())
if (year{Y} != ymd_trial.year())
goto broken;
if (m == not_a_month)
m = static_cast<int>(static_cast<unsigned>(ymd_trial.month()));
Expand Down

0 comments on commit aafcaf6

Please sign in to comment.