03d5044b31
This patch adds the C++20 calendar types and their methods as defined in [time.cal] (modulo the parsing/printing support). This patch also implements [time.hms] and [time.12], and a few more bits of [time.clock]. The remaining C++20 additions to <chrono> from P0355 and P1466 depend on [time.zone] and <format>, so they will come later, as will more optimized versions of some of the algorithms added here. The non-member operator overloads for the calendar types are defined as namespace-scope functions in the standard, but here we instead define these operator overloads as hidden friends. This simplifies the implementation somewhat and lets us reap the benefits of hidden friends for these overloads. The bulk of this work is based on a patch from Ed Smith-Rowland, which can be found at the Git branch users/redi/heads/calendar. Co-authored-by: Ed Smith-Rowland <3dw4rd@verizon.net> Co-authored-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/std/chrono (time_point::operator++) (time_point::operator--): Define. (utc_clock, tai_clock, gps_clock): Forward declare. (utc_time, utc_seconds, tai_time, tai_seconds, gps_time) (gps_seconds): Define. (is_clock<utc_clock>, is_clock<tai_clock>, is_clock<gps_clock>) (is_clock_v<utc_clock>, is_clock_v<tai_clock>) (is_clock_v<gps_clock>): Define these specializations. (leap_second_info): Define. (day, month, year, weekday, weekday_indexed) (weekday_last, month_day, month_day_last, month_weekday) (month_weekday_last, year_month, year_month_day) (year_month_day_last, year_month_weekday, year_month_weekday_last): Declare and later define. (last_spec, last, __detail::__days_per_month) (__detail::__days_per_month, __detail::__last_day): Define. (January, February, March, April, May, June, July, August) (September, October, November, December, Sunday, Monday, Tuesday) (Wednesday, Thursday, Friday, Saturday): Define. (weekday::operator[]): Define out-of-line. (year_month_day::_S_from_days, year_month_day::M_days_since_epoch): Likewise. (year_month_day::year_month_day, year_month_day::ok): Likewise. (__detail::__pow10, hh_mm_ss): Define. (literals::chrono_literals::operator""d) (literals::chrono_literals::operator""y): Define. (is_am, is_pm, make12, make24): Define. * testsuite/20_util/time_point/4.cc: New test. * testsuite/std/time/day/1.cc: New test. * testsuite/std/time/hh_mm_ss/1.cc: New test. * testsuite/std/time/is_am/1.cc: New test. * testsuite/std/time/is_pm/1.cc: New test. * testsuite/std/time/make12/1.cc: New test. * testsuite/std/time/make24/1.cc: New test. * testsuite/std/time/month/1.cc: New test. * testsuite/std/time/month_day/1.cc: New test. * testsuite/std/time/month_day_last/1.cc: New test. * testsuite/std/time/month_weekday/1.cc: New test. * testsuite/std/time/month_weekday_last/1.cc: New test. * testsuite/std/time/weekday/1.cc: New test. * testsuite/std/time/weekday_indexed/1.cc: New test. * testsuite/std/time/weekday_last/1.cc: New test. * testsuite/std/time/year/1.cc: New test. * testsuite/std/time/year_month/1.cc: New test. * testsuite/std/time/year_month_day/1.cc: New test. * testsuite/std/time/year_month_day_last/1.cc: New test. * testsuite/std/time/year_month_weekday/1.cc: New test. * testsuite/std/time/year_month_weekday_last/1.cc: New test. |
||
---|---|---|
.. | ||
arithmetic | ||
comparison_operators | ||
cons | ||
nonmember | ||
requirements | ||
1.cc | ||
2.cc | ||
3.cc | ||
4.cc |