mirror of
https://github.com/HowardHinnant/date.git
synced 2024-12-27 00:14:07 +08:00
Protect from overflow when minutes is 32 bits
This commit is contained in:
parent
630d67ce0d
commit
a89aab05cf
4
date.h
4
date.h
@ -3633,7 +3633,7 @@ public:
|
||||
|
||||
CONSTCD14 explicit operator precision() const NOEXCEPT
|
||||
{
|
||||
return to24hr() + m_ + s_;
|
||||
return to24hr() + s_ + m_;
|
||||
}
|
||||
|
||||
CONSTCD14 precision to_duration() const NOEXCEPT
|
||||
@ -3714,7 +3714,7 @@ public:
|
||||
|
||||
CONSTCD14 explicit operator precision() const NOEXCEPT
|
||||
{
|
||||
return to24hr() + m_ + s_ + sub_s_;
|
||||
return to24hr() + s_ + sub_s_ + m_;
|
||||
}
|
||||
|
||||
CONSTCD14 precision to_duration() const NOEXCEPT
|
||||
|
5
tz.cpp
5
tz.cpp
@ -708,7 +708,8 @@ MonthDayTime::to_sys_days(date::year y) const
|
||||
sys_seconds
|
||||
MonthDayTime::to_time_point(date::year y) const
|
||||
{
|
||||
return to_sys_days(y) + h_ + m_ + s_;
|
||||
// Add seconds first to promote to largest rep early to prevent overflow
|
||||
return to_sys_days(y) + s_ + h_ + m_;
|
||||
}
|
||||
|
||||
void
|
||||
@ -871,7 +872,7 @@ operator<<(std::ostream& os, const MonthDayTime& x)
|
||||
}
|
||||
break;
|
||||
}
|
||||
os << date::make_time(x.h_ + x.m_ + x.s_);
|
||||
os << date::make_time(x.s_ + x.h_ + x.m_);
|
||||
if (x.zone_ == tz::utc)
|
||||
os << "UTC ";
|
||||
else if (x.zone_ == tz::standard)
|
||||
|
Loading…
x
Reference in New Issue
Block a user