mirror of
https://github.com/HowardHinnant/date.git
synced 2025-01-14 17:58:03 +08:00
Enable streaming output operator for floating-point-based time_points
This commit is contained in:
parent
b5b765f928
commit
9a9a42db74
@ -1020,6 +1020,7 @@ protected:
|
|||||||
std::basic_ios<CharT, Traits>& is_;
|
std::basic_ios<CharT, Traits>& is_;
|
||||||
CharT fill_;
|
CharT fill_;
|
||||||
std::ios::fmtflags flags_;
|
std::ios::fmtflags flags_;
|
||||||
|
std::streamsize precision_;
|
||||||
std::streamsize width_;
|
std::streamsize width_;
|
||||||
std::basic_ostream<CharT, Traits>* tie_;
|
std::basic_ostream<CharT, Traits>* tie_;
|
||||||
std::locale loc_;
|
std::locale loc_;
|
||||||
@ -1029,6 +1030,7 @@ public:
|
|||||||
{
|
{
|
||||||
is_.fill(fill_);
|
is_.fill(fill_);
|
||||||
is_.flags(flags_);
|
is_.flags(flags_);
|
||||||
|
is_.precision(precision_);
|
||||||
is_.width(width_);
|
is_.width(width_);
|
||||||
is_.imbue(loc_);
|
is_.imbue(loc_);
|
||||||
is_.tie(tie_);
|
is_.tie(tie_);
|
||||||
@ -1041,6 +1043,7 @@ public:
|
|||||||
: is_(is)
|
: is_(is)
|
||||||
, fill_(is.fill())
|
, fill_(is.fill())
|
||||||
, flags_(is.flags())
|
, flags_(is.flags())
|
||||||
|
, precision_(is.precision())
|
||||||
, width_(is.width(0))
|
, width_(is.width(0))
|
||||||
, tie_(is.tie(nullptr))
|
, tie_(is.tie(nullptr))
|
||||||
, loc_(is.getloc())
|
, loc_(is.getloc())
|
||||||
@ -3997,6 +4000,7 @@ public:
|
|||||||
std::chrono::duration<rep> d = s_ + sub_s_;
|
std::chrono::duration<rep> d = s_ + sub_s_;
|
||||||
if (d < std::chrono::seconds{10})
|
if (d < std::chrono::seconds{10})
|
||||||
os << '0';
|
os << '0';
|
||||||
|
os.precision(width+6);
|
||||||
os << std::fixed << d.count();
|
os << std::fixed << d.count();
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
@ -4187,9 +4191,7 @@ make24(std::chrono::hours h, bool is_pm) NOEXCEPT
|
|||||||
template <class Duration>
|
template <class Duration>
|
||||||
using time_of_day = hh_mm_ss<Duration>;
|
using time_of_day = hh_mm_ss<Duration>;
|
||||||
|
|
||||||
template <class Rep, class Period,
|
template <class Rep, class Period>
|
||||||
class = typename std::enable_if
|
|
||||||
<!std::chrono::treat_as_floating_point<Rep>::value>::type>
|
|
||||||
CONSTCD11
|
CONSTCD11
|
||||||
inline
|
inline
|
||||||
hh_mm_ss<std::chrono::duration<Rep, Period>>
|
hh_mm_ss<std::chrono::duration<Rep, Period>>
|
||||||
@ -4202,8 +4204,7 @@ template <class CharT, class Traits, class Duration>
|
|||||||
inline
|
inline
|
||||||
typename std::enable_if
|
typename std::enable_if
|
||||||
<
|
<
|
||||||
!std::chrono::treat_as_floating_point<typename Duration::rep>::value &&
|
std::ratio_less<typename Duration::period, days::period>::value
|
||||||
std::ratio_less<typename Duration::period, days::period>::value
|
|
||||||
, std::basic_ostream<CharT, Traits>&
|
, std::basic_ostream<CharT, Traits>&
|
||||||
>::type
|
>::type
|
||||||
operator<<(std::basic_ostream<CharT, Traits>& os, const sys_time<Duration>& tp)
|
operator<<(std::basic_ostream<CharT, Traits>& os, const sys_time<Duration>& tp)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user