diff --git a/include/date/date.h b/include/date/date.h index 968f0ba..ae98d35 100644 --- a/include/date/date.h +++ b/include/date/date.h @@ -3652,11 +3652,11 @@ from_stream(std::basic_istream& is, const CharT* fmt, // time_of_day -enum {am = 1, pm}; - namespace detail { +struct undocumented {explicit undocumented() = default;}; + // width::value is the number of fractional decimal digits in 1/n // width<0>::value and width<1>::value are defined to be 0 // If 1/n takes more than 18 fractional decimal digits, @@ -3709,16 +3709,16 @@ struct make_precision static CONSTDATA unsigned width = 6; }; -template ::type::period::den>::value> +template class decimal_format_seconds { + using CT = typename std::common_type::type; + using rep = typename CT::rep; public: - using rep = typename std::common_type::type::rep; - using precision = typename make_precision::type; - static auto CONSTDATA width = make_precision::width; + static unsigned constexpr width = detail::width::value < 19 ? + detail::width::value : 6u; + using precision = std::chrono::duration::value>>; private: std::chrono::seconds s_; @@ -3759,25 +3759,27 @@ public: os.fill('0'); os.flags(std::ios::dec | std::ios::right); os.width(2); - os << x.s_.count() << - std::use_facet>(os.getloc()).decimal_point(); - os.width(width); - os << static_cast(x.sub_s_.count()); + os << x.s_.count(); + if (width > 0) + { + os << std::use_facet>(os.getloc()).decimal_point(); + os.width(width); + os << static_cast(x.sub_s_.count()); + } return os; } }; -template -class decimal_format_seconds +template +class decimal_format_seconds> { - static CONSTDATA unsigned w = 0; public: - using rep = typename std::common_type::type::rep; - using precision = std::chrono::duration; - static auto CONSTDATA width = make_precision::width; + static unsigned constexpr width = 0u; + using precision = std::chrono::duration; + private: - std::chrono::seconds s_; + precision s_; public: CONSTCD11 decimal_format_seconds() : s_() {} @@ -3800,39 +3802,13 @@ public: std::basic_ostream& operator<<(std::basic_ostream& os, const decimal_format_seconds& x) { - date::detail::save_ostream _(os); - os.fill('0'); - os.flags(std::ios::dec | std::ios::right); - os.width(2); + if (x.s_ < std::chrono::seconds{10}) + os << '0'; os << x.s_.count(); return os; } }; -enum class classify -{ - not_valid, - hour, - minute, - second, - subsecond -}; - -template -struct classify_duration -{ - static CONSTDATA classify value = - std::is_convertible::value - ? classify::hour : - std::is_convertible::value - ? classify::minute : - std::is_convertible::value - ? classify::second : - std::chrono::treat_as_floating_point::value - ? classify::not_valid : - classify::subsecond; -}; - template inline CONSTCD11 @@ -3859,490 +3835,160 @@ abs(std::chrono::duration d) return d; } -class time_of_day_base -{ -protected: - std::chrono::hours h_; - unsigned char mode_; - bool neg_; - - enum {is24hr}; - - CONSTCD11 time_of_day_base() NOEXCEPT - : h_(0) - , mode_(static_cast(is24hr)) - , neg_(false) - {} - - - CONSTCD11 time_of_day_base(std::chrono::hours h, bool neg, unsigned m) NOEXCEPT - : h_(detail::abs(h)) - , mode_(static_cast(m)) - , neg_(neg) - {} - - CONSTCD14 void make24() NOEXCEPT; - CONSTCD14 void make12() NOEXCEPT; - - CONSTCD14 std::chrono::hours to24hr() const; - - CONSTCD11 bool in_conventional_range() const NOEXCEPT - { - return !neg_ && h_ < days{1}; - } -}; - -CONSTCD14 -inline -std::chrono::hours -time_of_day_base::to24hr() const -{ - auto h = h_; - if (mode_ == am || mode_ == pm) - { - CONSTDATA auto h12 = std::chrono::hours(12); - if (mode_ == pm) - { - if (h != h12) - h = h + h12; - } - else if (h == h12) - h = std::chrono::hours(0); - } - return h; -} - -CONSTCD14 -inline -void -time_of_day_base::make24() NOEXCEPT -{ - h_ = to24hr(); - mode_ = is24hr; -} - -CONSTCD14 -inline -void -time_of_day_base::make12() NOEXCEPT -{ - if (mode_ == is24hr) - { - CONSTDATA auto h12 = std::chrono::hours(12); - if (h_ >= h12) - { - if (h_ > h12) - h_ = h_ - h12; - mode_ = pm; - } - else - { - if (h_ == std::chrono::hours(0)) - h_ = h12; - mode_ = am; - } - } -} - -template ::value> -class time_of_day_storage; - -template -class time_of_day_storage, detail::classify::hour> - : private detail::time_of_day_base -{ - using base = detail::time_of_day_base; - -public: - using precision = std::chrono::hours; - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 - CONSTCD11 time_of_day_storage() NOEXCEPT = default; -#else - CONSTCD11 time_of_day_storage() = default; -#endif /* !defined(_MSC_VER) || _MSC_VER >= 1900 */ - - CONSTCD11 explicit time_of_day_storage(std::chrono::hours since_midnight) NOEXCEPT - : base(since_midnight, since_midnight < std::chrono::hours{0}, is24hr) - {} - - CONSTCD11 explicit time_of_day_storage(std::chrono::hours h, unsigned md) NOEXCEPT - : base(h, h < std::chrono::hours{0}, md) - {} - - CONSTCD11 std::chrono::hours hours() const NOEXCEPT {return h_;} - CONSTCD11 unsigned mode() const NOEXCEPT {return mode_;} - - CONSTCD14 explicit operator precision() const NOEXCEPT - { - auto p = to24hr(); - if (neg_) - p = -p; - return p; - } - - CONSTCD14 precision to_duration() const NOEXCEPT - { - return static_cast(*this); - } - - CONSTCD14 time_of_day_storage& make24() NOEXCEPT {base::make24(); return *this;} - CONSTCD14 time_of_day_storage& make12() NOEXCEPT {base::make12(); return *this;} - - CONSTCD11 bool in_conventional_range() const NOEXCEPT - { - return base::in_conventional_range(); - } - - template - friend - std::basic_ostream& - operator<<(std::basic_ostream& os, const time_of_day_storage& t) - { - using namespace std; - detail::save_ostream _(os); - if (t.neg_) - os << '-'; - os.fill('0'); - os.flags(std::ios::dec | std::ios::right); - if (t.mode_ != am && t.mode_ != pm) - os.width(2); - os << t.h_.count(); - switch (t.mode_) - { - case time_of_day_storage::is24hr: - os << "00"; - break; - case am: - os << "am"; - break; - case pm: - os << "pm"; - break; - } - return os; - } -}; - -template -class time_of_day_storage, detail::classify::minute> - : private detail::time_of_day_base -{ - using base = detail::time_of_day_base; - - std::chrono::minutes m_; - -public: - using precision = std::chrono::minutes; - - CONSTCD11 time_of_day_storage() NOEXCEPT - : base() - , m_(0) - {} - - CONSTCD11 explicit time_of_day_storage(std::chrono::minutes since_midnight) NOEXCEPT - : base(std::chrono::duration_cast(since_midnight), - since_midnight < std::chrono::minutes{0}, is24hr) - , m_(detail::abs(since_midnight) - h_) - {} - - CONSTCD11 explicit time_of_day_storage(std::chrono::hours h, std::chrono::minutes m, - unsigned md) NOEXCEPT - : base(h, false, md) - , m_(m) - {} - - CONSTCD11 std::chrono::hours hours() const NOEXCEPT {return h_;} - CONSTCD11 std::chrono::minutes minutes() const NOEXCEPT {return m_;} - CONSTCD11 unsigned mode() const NOEXCEPT {return mode_;} - - CONSTCD14 explicit operator precision() const NOEXCEPT - { - auto p = to24hr() + m_; - if (neg_) - p = -p; - return p; - } - - CONSTCD14 precision to_duration() const NOEXCEPT - { - return static_cast(*this); - } - - CONSTCD14 time_of_day_storage& make24() NOEXCEPT {base::make24(); return *this;} - CONSTCD14 time_of_day_storage& make12() NOEXCEPT {base::make12(); return *this;} - - CONSTCD11 bool in_conventional_range() const NOEXCEPT - { - return base::in_conventional_range() && m_ < std::chrono::hours{1}; - } - - template - friend - std::basic_ostream& - operator<<(std::basic_ostream& os, const time_of_day_storage& t) - { - using namespace std; - detail::save_ostream _(os); - if (t.neg_) - os << '-'; - os.fill('0'); - os.flags(std::ios::dec | std::ios::right); - if (t.mode_ != am && t.mode_ != pm) - os.width(2); - os << t.h_.count() << ':'; - os.width(2); - os << t.m_.count(); - switch (t.mode_) - { - case am: - os << "am"; - break; - case pm: - os << "pm"; - break; - } - return os; - } -}; - -template -class time_of_day_storage, detail::classify::second> - : private detail::time_of_day_base -{ - using base = detail::time_of_day_base; - using dfs = decimal_format_seconds; - - std::chrono::minutes m_; - dfs s_; - -public: - using precision = std::chrono::seconds; - - CONSTCD11 time_of_day_storage() NOEXCEPT - : base() - , m_(0) - , s_() - {} - - CONSTCD11 explicit time_of_day_storage(std::chrono::seconds since_midnight) NOEXCEPT - : base(std::chrono::duration_cast(since_midnight), - since_midnight < std::chrono::seconds{0}, is24hr) - , m_(std::chrono::duration_cast(detail::abs(since_midnight) - h_)) - , s_(detail::abs(since_midnight) - h_ - m_) - {} - - CONSTCD11 explicit time_of_day_storage(std::chrono::hours h, std::chrono::minutes m, - std::chrono::seconds s, unsigned md) NOEXCEPT - : base(h, false, md) - , m_(m) - , s_(s) - {} - - CONSTCD11 std::chrono::hours hours() const NOEXCEPT {return h_;} - CONSTCD11 std::chrono::minutes minutes() const NOEXCEPT {return m_;} - CONSTCD14 std::chrono::seconds& seconds() NOEXCEPT {return s_.seconds();} - CONSTCD11 std::chrono::seconds seconds() const NOEXCEPT {return s_.seconds();} - CONSTCD11 unsigned mode() const NOEXCEPT {return mode_;} - - CONSTCD14 explicit operator precision() const NOEXCEPT - { - auto p = to24hr() + s_.to_duration() + m_; - if (neg_) - p = -p; - return p; - } - - CONSTCD14 precision to_duration() const NOEXCEPT - { - return static_cast(*this); - } - - CONSTCD14 time_of_day_storage& make24() NOEXCEPT {base::make24(); return *this;} - CONSTCD14 time_of_day_storage& make12() NOEXCEPT {base::make12(); return *this;} - - CONSTCD11 bool in_conventional_range() const NOEXCEPT - { - return base::in_conventional_range() && m_ < std::chrono::hours{1} && - s_.in_conventional_range(); - } - - template - friend - std::basic_ostream& - operator<<(std::basic_ostream& os, const time_of_day_storage& t) - { - using namespace std; - detail::save_ostream _(os); - if (t.neg_) - os << '-'; - os.fill('0'); - os.flags(std::ios::dec | std::ios::right); - if (t.mode_ != am && t.mode_ != pm) - os.width(2); - os << t.h_.count() << ':'; - os.width(2); - os << t.m_.count() << ':' << t.s_; - switch (t.mode_) - { - case am: - os << "am"; - break; - case pm: - os << "pm"; - break; - } - return os; - } - - template - friend - std::basic_ostream& - date::to_stream(std::basic_ostream& os, const CharT* fmt, - const fields& fds, const std::string* abbrev, - const std::chrono::seconds* offset_sec); - - template - friend - std::basic_istream& - date::from_stream(std::basic_istream& is, const CharT* fmt, - fields& fds, - std::basic_string* abbrev, std::chrono::minutes* offset); -}; - -template -class time_of_day_storage, detail::classify::subsecond> - : private detail::time_of_day_base -{ -public: - using Duration = std::chrono::duration; - using dfs = decimal_format_seconds::type>; - using precision = typename dfs::precision; - -private: - using base = detail::time_of_day_base; - - std::chrono::minutes m_; - dfs s_; - -public: - CONSTCD11 time_of_day_storage() NOEXCEPT - : base() - , m_(0) - , s_() - {} - - CONSTCD11 explicit time_of_day_storage(Duration since_midnight) NOEXCEPT - : base(date::trunc(since_midnight), - since_midnight < Duration{0}, is24hr) - , m_(date::trunc(detail::abs(since_midnight) - h_)) - , s_(detail::abs(since_midnight) - h_ - m_) - {} - - CONSTCD11 explicit time_of_day_storage(std::chrono::hours h, std::chrono::minutes m, - std::chrono::seconds s, precision sub_s, - unsigned md) NOEXCEPT - : base(h, false, md) - , m_(m) - , s_(s + sub_s) - {} - - CONSTCD11 std::chrono::hours hours() const NOEXCEPT {return h_;} - CONSTCD11 std::chrono::minutes minutes() const NOEXCEPT {return m_;} - CONSTCD14 std::chrono::seconds& seconds() NOEXCEPT {return s_.seconds();} - CONSTCD11 std::chrono::seconds seconds() const NOEXCEPT {return s_.seconds();} - CONSTCD11 precision subseconds() const NOEXCEPT {return s_.subseconds();} - CONSTCD11 unsigned mode() const NOEXCEPT {return mode_;} - - CONSTCD14 explicit operator precision() const NOEXCEPT - { - auto p = to24hr() + s_.to_duration() + m_; - if (neg_) - p = -p; - return p; - } - - CONSTCD14 precision to_duration() const NOEXCEPT - { - return static_cast(*this); - } - - CONSTCD14 time_of_day_storage& make24() NOEXCEPT {base::make24(); return *this;} - CONSTCD14 time_of_day_storage& make12() NOEXCEPT {base::make12(); return *this;} - - CONSTCD11 bool in_conventional_range() const NOEXCEPT - { - return base::in_conventional_range() && m_ < std::chrono::hours{1} && - s_.in_conventional_range(); - } - - template - friend - std::basic_ostream& - operator<<(std::basic_ostream& os, const time_of_day_storage& t) - { - using namespace std; - detail::save_ostream _(os); - if (t.neg_) - os << '-'; - os.fill('0'); - os.flags(std::ios::dec | std::ios::right); - if (t.mode_ != am && t.mode_ != pm) - os.width(2); - os << t.h_.count() << ':'; - os.width(2); - os << t.m_.count() << ':' << t.s_; - switch (t.mode_) - { - case am: - os << "am"; - break; - case pm: - os << "pm"; - break; - } - return os; - } - - template - friend - std::basic_ostream& - date::to_stream(std::basic_ostream& os, const CharT* fmt, - const fields& fds, const std::string* abbrev, - const std::chrono::seconds* offset_sec); - - template - friend - std::basic_istream& - date::from_stream(std::basic_istream& is, const CharT* fmt, - fields& fds, - std::basic_string* abbrev, std::chrono::minutes* offset); -}; - } // namespace detail template class time_of_day - : public detail::time_of_day_storage { - using base = detail::time_of_day_storage; + using dfs = detail::decimal_format_seconds::type>; + + enum state {is_24, am, pm}; + + std::chrono::hours h_; + std::chrono::minutes m_; + dfs s_; + bool neg_; + state mode_ = is_24; + public: -#if !defined(_MSC_VER) || _MSC_VER >= 1900 - CONSTCD11 time_of_day() NOEXCEPT = default; -#else + using precision = typename dfs::precision; + CONSTCD11 time_of_day() = default; -#endif /* !defined(_MSC_VER) || _MSC_VER >= 1900 */ - CONSTCD11 explicit time_of_day(Duration since_midnight) NOEXCEPT - : base(since_midnight) + CONSTCD11 explicit time_of_day(Duration d) NOEXCEPT + : h_(std::chrono::duration_cast(detail::abs(d))) + , m_(std::chrono::duration_cast(detail::abs(d)) - h_) + , s_(detail::abs(d) - h_ - m_) + , neg_(d < precision{}) {} - template - CONSTCD11 - explicit time_of_day(Arg0&& arg0, Arg1&& arg1, Args&& ...args) NOEXCEPT - : base(std::forward(arg0), std::forward(arg1), std::forward(args)...) - {} + CONSTCD11 std::chrono::hours hours() const NOEXCEPT {return h_;} + CONSTCD11 std::chrono::minutes minutes() const NOEXCEPT {return m_;} + CONSTCD11 std::chrono::seconds seconds() const NOEXCEPT {return s_.seconds();} + CONSTCD11 std::chrono::seconds& + seconds(detail::undocumented) NOEXCEPT {return s_.seconds();} + CONSTCD11 precision subseconds() const NOEXCEPT {return s_.subseconds();} + + CONSTCD11 explicit operator precision() const NOEXCEPT {return to_duration();} + CONSTCD11 precision to_duration() const NOEXCEPT + {return (make_24(mode_, h_) + m_ + s_.to_duration()) * (1-2*neg_);} + + CONSTCD14 void make24() NOEXCEPT + { + h_ = make_24(mode_, h_); + mode_ = is_24; + } + CONSTCD14 void make12() NOEXCEPT {make_12(mode_, h_);} + + CONSTCD11 bool in_conventional_range() const NOEXCEPT + { + using namespace std; + return !neg_ && h_ < days{1} && m_ < chrono::hours{1} && + s_.in_conventional_range(); + } + +private: + + CONSTCD14 + static + std::chrono::hours + make_24(state mode, std::chrono::hours h) NOEXCEPT + { + using namespace std; + if (mode != is_24) + { + if (mode == am) + { + if (h == chrono::hours{12}) + h = chrono::hours{0}; + } + else + { + if (h != chrono::hours{12}) + h += chrono::hours{12}; + } + } + return h; + } + + CONSTCD14 + static + void + make_12(state& mode, std::chrono::hours& h) NOEXCEPT + { + using namespace std; + if (mode == is_24) + { + if (h < chrono::hours{12}) + { + if (h == chrono::hours{0}) + h = chrono::hours{12}; + mode = am; + } + else + { + if (h != chrono::hours{12}) + h -= chrono::hours{12}; + mode = pm; + } + } + } + + template + friend + std::basic_ostream& + operator<<(std::basic_ostream& os, time_of_day const& tod) + { + using namespace detail; + using namespace std; + if (tod.neg_) + os << '-'; + if (tod.mode_ == is_24) + { + if (tod.h_ < chrono::hours{10}) + os << '0'; + os << tod.h_.count() << ':'; + if (tod.m_ < chrono::minutes{10}) + os << '0'; + os << tod.m_.count() << ':' << tod.s_; + } + else + { + os << tod.h_.count() << ':'; + if (tod.m_ < chrono::minutes{10}) + os << '0'; + os << tod.m_.count() << ':' << tod.s_; +#if !ONLY_C_LOCALE + std::tm tm{}; + tm.tm_hour = tod.make_24(tod.mode_, tod.h_).count(); + auto& facet = use_facet>(os.getloc()); + const charT f[] = {'%', 'p'}; + facet.put(os, os, os.fill(), &tm, f, f+2); +#else + if (tod.mode_ == am) + os << 'A'; + else + os << 'P'; + os << 'M'; +#endif + } + return os; + } + + template + friend + std::basic_ostream& + date::to_stream(std::basic_ostream& os, const CharT* fmt, + const fields& fds, const std::string* abbrev, + const std::chrono::seconds* offset_sec); + + template + friend + std::basic_istream& + date::from_stream(std::basic_istream& is, const CharT* fmt, + fields& fds, + std::basic_string* abbrev, std::chrono::minutes* offset); }; template & d) return time_of_day>(d); } -CONSTCD11 -inline -time_of_day -make_time(const std::chrono::hours& h, unsigned md) -{ - return time_of_day(h, md); -} - -CONSTCD11 -inline -time_of_day -make_time(const std::chrono::hours& h, const std::chrono::minutes& m, - unsigned md) -{ - return time_of_day(h, m, md); -} - -CONSTCD11 -inline -time_of_day -make_time(const std::chrono::hours& h, const std::chrono::minutes& m, - const std::chrono::seconds& s, unsigned md) -{ - return time_of_day(h, m, s, md); -} - -template >::value>::type> -CONSTCD11 -inline -time_of_day> -make_time(const std::chrono::hours& h, const std::chrono::minutes& m, - const std::chrono::seconds& s, const std::chrono::duration& sub_s, - unsigned md) -{ - return time_of_day>(h, m, s, sub_s, md); -} - template inline typename std::enable_if diff --git a/include/date/tz.h b/include/date/tz.h index 10f3782..7294076 100644 --- a/include/date/tz.h +++ b/include/date/tz.h @@ -1972,7 +1972,7 @@ to_stream(std::basic_ostream& os, const CharT* fmt, auto const sd = floor(tp); year_month_day ymd = sd; auto time = make_time(tp - sys_seconds{sd}); - time.seconds() += seconds{ls.first}; + time.seconds(detail::undocumented{}) += seconds{ls.first}; fields fds{ymd, time}; return to_stream(os, fmt, fds, &abbrev, &offset); } @@ -2004,7 +2004,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, { bool is_60_sec = fds.tod.seconds() == seconds{60}; if (is_60_sec) - fds.tod.seconds() -= seconds{1}; + fds.tod.seconds(detail::undocumented{}) -= seconds{1}; auto tmp = utc_clock::from_sys(sys_days(fds.ymd) - *offptr + fds.tod.to_duration()); if (is_60_sec) tmp += seconds{1}; diff --git a/src/tz.cpp b/src/tz.cpp index ac96512..faea57d 100644 --- a/src/tz.cpp +++ b/src/tz.cpp @@ -393,11 +393,6 @@ get_tz_dir() // | End Configuration | // +-------------------+ -namespace detail -{ -struct undocumented {explicit undocumented() = default;}; -} - #ifndef _MSC_VER static_assert(min_year <= max_year, "Configuration error"); #endif diff --git a/test/date_test/detail/decimal_format_seconds.pass.cpp b/test/date_test/detail/decimal_format_seconds.pass.cpp index dfb4619..cc8e3cd 100644 --- a/test/date_test/detail/decimal_format_seconds.pass.cpp +++ b/test/date_test/detail/decimal_format_seconds.pass.cpp @@ -94,7 +94,6 @@ main() { using D = decimal_format_seconds; static_assert(D::width == 3, ""); - static_assert(is_same::type>{}, ""); D dfs{seconds{3}}; assert(dfs.seconds() == seconds{3}); assert(dfs.to_duration() == seconds{3}); @@ -106,7 +105,6 @@ main() { using D = decimal_format_seconds; static_assert(D::width == 3, ""); - static_assert(is_same::type>{}, ""); D dfs{milliseconds{3}}; assert(dfs.seconds() == seconds{0}); assert(dfs.to_duration() == milliseconds{3}); @@ -118,9 +116,8 @@ main() { using D = decimal_format_seconds; static_assert(D::width == 4, ""); - using S = make_precision::type; - static_assert(is_same{}, ""); D dfs{microfortnights{3}}; + using S = D::precision; assert(dfs.seconds() == seconds{3}); assert(dfs.to_duration() == S{36288}); assert(dfs.subseconds() == S{6288}); @@ -132,9 +129,8 @@ main() using CT = common_type::type; using D = decimal_format_seconds; static_assert(D::width == 4, ""); - using S = make_precision::type; - static_assert(is_same{}, ""); D dfs{microfortnights{3}}; + using S = D::precision; assert(dfs.seconds() == seconds{3}); assert(dfs.to_duration() == S{36288}); assert(dfs.subseconds() == S{6288}); diff --git a/test/date_test/make_time.pass.cpp b/test/date_test/make_time.pass.cpp index ec371ae..f203807 100644 --- a/test/date_test/make_time.pass.cpp +++ b/test/date_test/make_time.pass.cpp @@ -27,27 +27,6 @@ // time_of_day> // make_time(std::chrono::duration d) noexcept; -// constexpr -// time_of_day -// make_time(std::chrono::hours h, unsigned md) noexcept; - -// constexpr -// time_of_day -// make_time(std::chrono::hours h, std::chrono::minutes m, unsigned md) noexcept; - -// constexpr -// time_of_day -// make_time(std::chrono::hours h, std::chrono::minutes m, std::chrono::seconds s, -// unsigned md) noexcept; - -// template >::value>::type> -// constexpr -// time_of_day> -// make_time(std::chrono::hours h, std::chrono::minutes m, std::chrono::seconds s, -// std::chrono::duration sub_s, unsigned md) noexcept; - #include "date.h" #include @@ -68,7 +47,6 @@ main() assert(tod.minutes() == minutes{7}); assert(tod.seconds() == seconds{9}); assert(tod.subseconds() == nanoseconds{22}); - assert(tod.mode() == 0); } { static_assert(is_same>{}, ""); auto tod = make_time(hours{5}); assert(tod.hours() == hours{5}); - assert(tod.mode() == 0); - } - { - static_assert(is_same>{}, ""); - auto tod = make_time(hours{5}, minutes{7}, seconds{9}, nanoseconds{22}, pm); - assert(tod.hours() == hours{5}); - assert(tod.minutes() == minutes{7}); - assert(tod.seconds() == seconds{9}); - assert(tod.subseconds() == nanoseconds{22}); - assert(tod.mode() == pm); - } - { - static_assert(is_same>{}, ""); - auto tod = make_time(hours{5}, minutes{7}, seconds{9}, microseconds{22}, 0); - assert(tod.hours() == hours{5}); - assert(tod.minutes() == minutes{7}); - assert(tod.seconds() == seconds{9}); - assert(tod.subseconds() == microseconds{22}); - assert(tod.mode() == 0); - } - { - static_assert(is_same>{}, ""); - auto tod = make_time(hours{5}, minutes{7}, seconds{9}, milliseconds{22}, am); - assert(tod.hours() == hours{5}); - assert(tod.minutes() == minutes{7}); - assert(tod.seconds() == seconds{9}); - assert(tod.subseconds() == milliseconds{22}); - assert(tod.mode() == am); - } - { - static_assert(is_same>{}, ""); - auto tod = make_time(hours{5}, minutes{7}, seconds{9}, am); - assert(tod.hours() == hours{5}); - assert(tod.minutes() == minutes{7}); - assert(tod.seconds() == seconds{9}); - assert(tod.mode() == am); - } - { - static_assert(is_same>{}, ""); - auto tod = make_time(hours{5}, minutes{7}, pm); - assert(tod.hours() == hours{5}); - assert(tod.minutes() == minutes{7}); - assert(tod.mode() == pm); - } - { - static_assert(is_same>{}, ""); - auto tod = make_time(hours{5}, 0); - assert(tod.hours() == hours{5}); - assert(tod.mode() == 0); } } diff --git a/test/date_test/time_of_day_hours.pass.cpp b/test/date_test/time_of_day_hours.pass.cpp index 85ebb50..0768468 100644 --- a/test/date_test/time_of_day_hours.pass.cpp +++ b/test/date_test/time_of_day_hours.pass.cpp @@ -57,7 +57,7 @@ main() using tod = time_of_day; - static_assert(is_same{}, ""); + static_assert(is_same{}, ""); static_assert( is_trivially_destructible{}, ""); static_assert( is_default_constructible{}, ""); @@ -74,7 +74,6 @@ main() constexpr tod t1 = tod{hours{13}}; static_assert(t1.hours() == hours{13}, ""); - static_assert(t1.mode() == 0, ""); #if __cplusplus >= 201402 static_assert(static_cast(t1) == hours{13}, ""); static_assert(t1.to_duration() == hours{13}, ""); @@ -82,23 +81,20 @@ main() auto t2 = t1; assert(t2.hours() == t1.hours()); - assert(t2.mode() == t1.mode()); assert(t2.to_duration() == t1.to_duration()); ostringstream os; os << t2; - assert(os.str() == "1300"); + assert(os.str() == "13:00:00"); t2.make12(); os.str(""); assert(t2.hours() == hours{1}); - assert(t2.mode() == pm); assert(t2.to_duration() == t1.to_duration()); os << t2; - assert(os.str() == "1pm"); + assert(os.str() == "1:00:00PM"); t2.make24(); os.str(""); assert(t2.hours() == hours{13}); - assert(t2.mode() == 0); assert(t2.to_duration() == t1.to_duration()); os << t2; - assert(os.str() == "1300"); + assert(os.str() == "13:00:00"); } diff --git a/test/date_test/time_of_day_microfortnights.pass.cpp b/test/date_test/time_of_day_microfortnights.pass.cpp index ce48da4..6267f0c 100644 --- a/test/date_test/time_of_day_microfortnights.pass.cpp +++ b/test/date_test/time_of_day_microfortnights.pass.cpp @@ -111,7 +111,7 @@ main() t2.make12(); os.str(""); os << t2; - assert(os.str() == "1:07:06.0480pm"); + assert(os.str() == "1:07:06.0480PM"); t2.make24(); os.str(""); os << t2; diff --git a/test/date_test/time_of_day_milliseconds.pass.cpp b/test/date_test/time_of_day_milliseconds.pass.cpp index 30d690d..7d7ba69 100644 --- a/test/date_test/time_of_day_milliseconds.pass.cpp +++ b/test/date_test/time_of_day_milliseconds.pass.cpp @@ -85,7 +85,6 @@ main() static_assert(t1.minutes() == minutes{7}, ""); static_assert(t1.seconds() == seconds{5}, ""); static_assert(t1.subseconds() == milliseconds{22}, ""); - static_assert(t1.mode() == 0, ""); #if __cplusplus >= 201402 static_assert(static_cast(t1) == hours{13} + minutes{7} + seconds{5} + milliseconds{22}, ""); @@ -98,7 +97,6 @@ main() assert(t2.minutes() == t1.minutes()); assert(t2.seconds() == t1.seconds()); assert(t2.subseconds() == t1.subseconds()); - assert(t2.mode() == t1.mode()); assert(t2.to_duration() == t1.to_duration()); ostringstream os; os << t2; @@ -109,17 +107,15 @@ main() assert(t2.minutes() == minutes{7}); assert(t2.seconds() == seconds{5}); assert(t2.subseconds() == milliseconds{22}); - assert(t2.mode() == pm); assert(t2.to_duration() == t1.to_duration()); os << t2; - assert(os.str() == "1:07:05.022pm"); + assert(os.str() == "1:07:05.022PM"); t2.make24(); os.str(""); assert(t2.hours() == hours{13}); assert(t2.minutes() == minutes{7}); assert(t2.seconds() == seconds{5}); assert(t2.subseconds() == milliseconds{22}); - assert(t2.mode() == 0); assert(t2.to_duration() == t1.to_duration()); os << t2; assert(os.str() == "13:07:05.022"); diff --git a/test/date_test/time_of_day_minutes.pass.cpp b/test/date_test/time_of_day_minutes.pass.cpp index dda8710..2102a47 100644 --- a/test/date_test/time_of_day_minutes.pass.cpp +++ b/test/date_test/time_of_day_minutes.pass.cpp @@ -59,7 +59,7 @@ main() using tod = time_of_day; - static_assert(is_same{}, ""); + static_assert(is_same{}, ""); static_assert( is_trivially_destructible{}, ""); static_assert( is_default_constructible{}, ""); @@ -77,7 +77,6 @@ main() constexpr tod t1 = tod{hours{13} + minutes{7}}; static_assert(t1.hours() == hours{13}, ""); static_assert(t1.minutes() == minutes{7}, ""); - static_assert(t1.mode() == 0, ""); #if __cplusplus >= 201402 static_assert(static_cast(t1) == hours{13} + minutes{7}, ""); static_assert(t1.to_duration() == hours{13} + minutes{7}, ""); @@ -86,25 +85,22 @@ main() auto t2 = t1; assert(t2.hours() == t1.hours()); assert(t2.minutes() == t1.minutes()); - assert(t2.mode() == t1.mode()); assert(t2.to_duration() == t1.to_duration()); ostringstream os; os << t2; - assert(os.str() == "13:07"); + assert(os.str() == "13:07:00"); t2.make12(); os.str(""); assert(t2.hours() == hours{1}); assert(t2.minutes() == minutes{7}); - assert(t2.mode() == pm); assert(t2.to_duration() == t1.to_duration()); os << t2; - assert(os.str() == "1:07pm"); + assert(os.str() == "1:07:00PM"); t2.make24(); os.str(""); assert(t2.hours() == hours{13}); assert(t2.minutes() == minutes{7}); - assert(t2.mode() == 0); assert(t2.to_duration() == t1.to_duration()); os << t2; - assert(os.str() == "13:07"); + assert(os.str() == "13:07:00"); } diff --git a/test/date_test/time_of_day_nanoseconds.pass.cpp b/test/date_test/time_of_day_nanoseconds.pass.cpp index 9d5e456..73748bf 100644 --- a/test/date_test/time_of_day_nanoseconds.pass.cpp +++ b/test/date_test/time_of_day_nanoseconds.pass.cpp @@ -85,7 +85,6 @@ main() static_assert(t1.minutes() == minutes{7}, ""); static_assert(t1.seconds() == seconds{5}, ""); static_assert(t1.subseconds() == nanoseconds{22}, ""); - static_assert(t1.mode() == 0, ""); #if __cplusplus >= 201402 static_assert(static_cast(t1) == hours{13} + minutes{7} + seconds{5} + nanoseconds{22}, ""); @@ -98,7 +97,6 @@ main() assert(t2.minutes() == t1.minutes()); assert(t2.seconds() == t1.seconds()); assert(t2.subseconds() == t1.subseconds()); - assert(t2.mode() == t1.mode()); assert(t2.to_duration() == t1.to_duration()); ostringstream os; os << t2; @@ -109,17 +107,15 @@ main() assert(t2.minutes() == minutes{7}); assert(t2.seconds() == seconds{5}); assert(t2.subseconds() == nanoseconds{22}); - assert(t2.mode() == pm); assert(t2.to_duration() == t1.to_duration()); os << t2; - assert(os.str() == "1:07:05.000000022pm"); + assert(os.str() == "1:07:05.000000022PM"); t2.make24(); os.str(""); assert(t2.hours() == hours{13}); assert(t2.minutes() == minutes{7}); assert(t2.seconds() == seconds{5}); assert(t2.subseconds() == nanoseconds{22}); - assert(t2.mode() == 0); assert(t2.to_duration() == t1.to_duration()); os << t2; assert(os.str() == "13:07:05.000000022"); diff --git a/test/date_test/time_of_day_seconds.pass.cpp b/test/date_test/time_of_day_seconds.pass.cpp index 09dec9e..a6e84b9 100644 --- a/test/date_test/time_of_day_seconds.pass.cpp +++ b/test/date_test/time_of_day_seconds.pass.cpp @@ -79,7 +79,6 @@ main() static_assert(t1.hours() == hours{13}, ""); static_assert(t1.minutes() == minutes{7}, ""); static_assert(t1.seconds() == seconds{5}, ""); - static_assert(t1.mode() == 0, ""); #if __cplusplus >= 201402 static_assert(static_cast(t1) == hours{13} + minutes{7} + seconds{5}, ""); @@ -90,7 +89,6 @@ main() assert(t2.hours() == t1.hours()); assert(t2.minutes() == t1.minutes()); assert(t2.seconds() == t1.seconds()); - assert(t2.mode() == t1.mode()); assert(t2.to_duration() == t1.to_duration()); ostringstream os; os << t2; @@ -100,16 +98,14 @@ main() assert(t2.hours() == hours{1}); assert(t2.minutes() == minutes{7}); assert(t2.seconds() == seconds{5}); - assert(t2.mode() == pm); assert(t2.to_duration() == t1.to_duration()); os << t2; - assert(os.str() == "1:07:05pm"); + assert(os.str() == "1:07:05PM"); t2.make24(); os.str(""); assert(t2.hours() == hours{13}); assert(t2.minutes() == minutes{7}); assert(t2.seconds() == seconds{5}); - assert(t2.mode() == 0); assert(t2.to_duration() == t1.to_duration()); os << t2; assert(os.str() == "13:07:05");