mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-02 12:14:27 +02:00
Protect from overflow when minutes is 32 bits
This commit is contained in:
4
date.h
4
date.h
@@ -3633,7 +3633,7 @@ public:
|
|||||||
|
|
||||||
CONSTCD14 explicit operator precision() const NOEXCEPT
|
CONSTCD14 explicit operator precision() const NOEXCEPT
|
||||||
{
|
{
|
||||||
return to24hr() + m_ + s_;
|
return to24hr() + s_ + m_;
|
||||||
}
|
}
|
||||||
|
|
||||||
CONSTCD14 precision to_duration() const NOEXCEPT
|
CONSTCD14 precision to_duration() const NOEXCEPT
|
||||||
@@ -3714,7 +3714,7 @@ public:
|
|||||||
|
|
||||||
CONSTCD14 explicit operator precision() const NOEXCEPT
|
CONSTCD14 explicit operator precision() const NOEXCEPT
|
||||||
{
|
{
|
||||||
return to24hr() + m_ + s_ + sub_s_;
|
return to24hr() + s_ + sub_s_ + m_;
|
||||||
}
|
}
|
||||||
|
|
||||||
CONSTCD14 precision to_duration() const NOEXCEPT
|
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
|
sys_seconds
|
||||||
MonthDayTime::to_time_point(date::year y) const
|
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
|
void
|
||||||
@@ -871,7 +872,7 @@ operator<<(std::ostream& os, const MonthDayTime& x)
|
|||||||
}
|
}
|
||||||
break;
|
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)
|
if (x.zone_ == tz::utc)
|
||||||
os << "UTC ";
|
os << "UTC ";
|
||||||
else if (x.zone_ == tz::standard)
|
else if (x.zone_ == tz::standard)
|
||||||
|
Reference in New Issue
Block a user