标准库头文件 <chrono>
来自cppreference.com
此头文件是日期和时间库的一部分。
包含 | |
(C++20) |
三路比较运算符支持 |
类 | |
时长 | |
定义于命名空间
std::chrono | |
(C++11) |
时间区间 (类模板) |
(C++11) |
指示时长可转换为拥有不同计次的时长 (类模板) |
(C++11) |
构造给定类型计次的零、最小及最大值 (类模板) |
便利时长 typedef | |
定义于命名空间
std::chrono | |
std::chrono::nanoseconds(C++11) | Period 为 std::nano 的时长类型 |
std::chrono::microseconds(C++11) | Period 为 std::micro 的时长类型 |
std::chrono::milliseconds(C++11) | Period 为 std::milli 的时长类型 |
std::chrono::seconds(C++11) | Period 为 std::ratio<1> 的时长类型 |
std::chrono::minutes(C++11) | Period 为 std::ratio<60> 的时长类型 |
std::chrono::hours(C++11) | Period 为 std::ratio<3600> 的时长类型 |
std::chrono::days(C++20) | Period 为 std::ratio<86400> 的时长类型 |
std::chrono::weeks(C++20) | Period 为 std::ratio<604800> 的时长类型 |
std::chrono::months(C++20) | Period 为 std::ratio<2629746> 的时长类型 |
std::chrono::years(C++20) | Period 为 std::ratio<31556952> 的时长类型 |
时间点 | |
定义于命名空间
std::chrono | |
(C++11) |
时间中的点 (类模板) |
(C++20) |
定义如何转换一个时钟的时间点为另一个的特性类 (类模板) |
时钟 | |
定义于命名空间
std::chrono | |
(C++20) |
确定类型是否为时钟 (Clock) (类模板) (变量模板) |
(C++11) |
来自系统范畴实时时钟的挂钟时间 (类) |
(C++11) |
决不会调整的单调时钟 (类) |
(C++11) |
拥有可用的最短嘀嗒周期的时钟 (类) |
(C++20) |
协调世界时 (UTC) 的时钟 (Clock) (类) |
(C++20) |
国际原子时 (TAI) 的时钟 (Clock) (类) |
(C++20) |
GPS 时间的时钟 (Clock) (类) |
(C++20) |
用于文件时间的时钟 (Clock) (typedef) |
(C++20) |
表示本地时间的伪时钟 (类) |
日历 | |
定义于命名空间
std::chrono | |
(C++20) |
指示一个月中最后日期或星期的标签类 (类) |
(C++20) |
表示月之日期 (类) |
(C++20) |
表示年之月份 (类) |
(C++20) |
表示格里高利历中的年 (类) |
(C++20) |
表示格里高利历中星期之日 (类) |
(C++20) |
表示月份的第 n 个 weekday (类) |
(C++20) |
表示月份的最后一个 weekday (类) |
(C++20) |
表示特定 month 的特定 day (类) |
(C++20) |
表示特定 month 的最后一日 (类) |
(C++20) |
表示特定 month 的第 n 个 weekday (类) |
(C++20) |
表示特定 month 的最后一个 weekday (类) |
(C++20) |
表示特定 year 的特定 month (类) |
(C++20) |
表示特定的 year 、 month 和 day (类) |
(C++20) |
表示特定 year 和 month 的最后一日 (类) |
(C++20) |
表示特定 year 和 month 的第 n 个 weekday (类) |
(C++20) |
表示特定 year 和 month 的最后一个 weekday (类) |
当天时刻 | |
定义于命名空间
std::chrono | |
(C++20) |
表示当天时刻 (类模板) |
时区 | |
定义于命名空间
std::chrono | |
(C++20) |
描述 IANA 时区数据库的副本 (类) |
(C++20) |
表示 tzdb 的链表 (类) |
(C++20) |
表示时区 (类) |
(C++20) |
表示在特定时间点的关于时区的信息 (类) |
(C++20) |
表示关于从本地时间转换到 UNIX 时间的信息 (类) |
(C++20) |
选择应如何解析歧义的本地时间 (枚举) |
(C++20) |
zoned_time 所用的时区指针的特性类 (类模板) |
(C++20) |
表示时区和时间点 (类) |
(C++20) |
表示时区的替用名 (类) |
(C++20) |
抛出以报告本地时间不存在的异常 (类) |
(C++20) |
抛出以报告本地时间有歧义的异常 (类) |
闰秒 | |
定义于命名空间
std::chrono | |
(C++20) |
含有关于插入闰秒的信息 (类) |
(C++20) |
闰秒插入信息 (类) |
特化 | |
定义于命名空间
std |
特化 std::common_type 特征 (类模板特化) | |
特化 std::common_type 特征 (类模板特化) |
std::formatter 的特化,按提供的格式格式化 duration (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 sys_time (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 utc_time (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 tai_time (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 gps_time (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 file_time (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 local_time (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 day (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 month (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 year (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 weekday (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 weekday_indexed (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 weekday_last (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 month_day (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 month_day_last (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 month_weekday (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 month_weekday_last (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 year_month (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 year_month_day (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 year_month_day_last (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 year_month_weekday (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 year_month_weekday_last (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 hh_mm_ss (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 sys_info (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 local_info (类模板特化) | |
std::formatter 的特化,按照提供的格式格式化 zoned_time (类模板特化) |
函数 | |
时长 | |
定义于命名空间
std::chrono | |
实现以时长为实参的算术运算 (函数模板) | |
(C++11)(C++11)(C++20 中移除)(C++11)(C++11)(C++11)(C++11)(C++20) |
比较两个时长 (函数模板) |
(C++11) |
转换时长到另一个拥有不同嘀嗒间隔的时长 (函数模板) |
(C++17) |
以向下取整的方式,将一个时长转换为另一个时长 (函数模板) |
(C++17) |
以向上取整的方式,将一个时长转换为另一个时长 (函数模板) |
(C++17) |
转换时长到另一个时长,就近取整,偶数优先 (函数模板) |
(C++17) |
获取时长的绝对值 (函数模板) |
时间点 | |
定义于命名空间
std::chrono | |
(C++11) |
实施涉及时间点的加法和减法运算 (函数模板) |
(C++11)(C++11)(C++20 中移除)(C++11)(C++11)(C++11)(C++11)(C++20) |
比较两个时间点 (函数模板) |
(C++11) |
转换时间点为同一时钟上拥有不同时长的另一时间点 (函数模板) |
转换 time_point 到另一个,向下取整 (函数模板) | |
转换 time_point 到另一个,向上取整 (函数模板) | |
转换 time_point 到另一个,就近取整,偶数优先 (函数模板) | |
按照给定的格式从流分析 sys_time (函数模板) | |
按照给定的格式从流分析 utc_time (函数模板) | |
按照给定的格式从流分析 tai_time (函数模板) | |
按照给定的格式从流分析 gps_time (函数模板) | |
按照给定的格式从流分析 file_time (函数模板) | |
按照给定的格式从流分析 local_time (函数模板) | |
(C++20) |
转换一个时钟的时间点为另一个 (函数模板) |
日历 | |
定义于命名空间
std::chrono | |
(C++20) |
比较二个 day 值 (函数) |
(C++20) |
比较二个 month 值 (函数) |
(C++20) |
比较二个 year 值 (函数) |
(C++20) |
比较二个 weekday 值 (函数) |
(C++20) |
比较二个 weekday_indexed 值 (函数) |
(C++20) |
比较二个 weekday_last 值 (函数) |
(C++20) |
比较二个 month_day 值 (函数) |
(C++20) |
比较二个 month_day_last 值 (函数) |
(C++20) |
比较二个 month_weekday 值 (函数) |
(C++20) |
比较二个 month_weekday_last 值 (函数) |
(C++20) |
比较二个 year_month 值 (函数) |
(C++20) |
比较二个 year_month_day 值 (函数) |
(C++20) |
比较二个 year_month_day_last 值 (函数) |
(C++20) |
比较二个 year_month_weekday 值 (函数) |
(C++20) |
比较二个 year_month_weekday_last 值 (函数) |
(C++20) |
加或减日数和 day ,或求二个 day 间的差 (函数) |
(C++20) |
进行 month 上的算术 (函数) |
(C++20) |
进行 year 上的算术 (函数) |
(C++20) |
在 weekday 上进行算术 (函数) |
(C++20) |
进行 year_month 上的算术 (函数) |
(C++20) |
将 year_month_day 与一定量的年数或月数相加或相减 (函数) |
(C++20) |
将 year_month_day_last 和一定数量的 years 或 months 相加或相减 (函数) |
(C++20) |
将 year_month_weekday 与一定数量的 years 或 months 相加或相减 (函数) |
(C++20) |
将 year_month_weekday_last 与一定数量的 years 或 months 相加或相减 (函数) |
(C++20) |
创建格里高利历日期的约定语法 (函数) |
当天时刻 | |
定义于命名空间
std::chrono | |
(C++20) |
在 12 时和 24 时格式当天时刻之间翻译 (函数) |
时区 | |
定义于命名空间
std::chrono | |
访问和控制全球时区数据库信息 (函数) | |
(C++20) |
定位基于其名称的 time_zone (函数) |
(C++20) |
比较二个 time_zone 对象 (函数) |
(C++20) |
比较二个 zoned_time 值 (函数模板) |
(C++20) |
比较二个 time_zone_link 对象 (函数) |
闰秒 | |
定义于命名空间
std::chrono | |
(C++20) |
从 utc_time 对象获得闰秒插入信息 (函数模板) |
比较二个 leap_second 值或一个 leap_second 值与一个 sys_time (函数模板) | |
I/O | |
定义于命名空间
std::chrono | |
(C++20) |
进行 duration 上的流输出 (函数模板) |
进行 sys_time 上的流输出 (函数模板) | |
进行 utc_time 上的流输出 (函数模板) | |
进行 tai_time 上的流输出 (函数模板) | |
进行 gps_time 上的流输出 (函数模板) | |
进行 file_time 上的流输出 (函数模板) | |
(C++20) |
输出 day 到流 (函数模板) |
(C++20) |
输出 month 到流中 (函数模板) |
(C++20) |
输出 year 到流 (函数模板) |
(C++20) |
输出 weekday 到流中 (函数模板) |
(C++20) |
输出 weekday_indexed 到流中 (函数模板) |
(C++20) |
输出 weekday_last 到流中 (函数模板) |
(C++20) |
输出 month_day 到流中 (函数模板) |
(C++20) |
输出 month_day_last 到流中 (函数模板) |
(C++20) |
输出 month_weekday 到流中 (函数模板) |
(C++20) |
输出 month_weekday_last 到流中 (函数模板) |
(C++20) |
输出 year_month 到流中 (函数模板) |
(C++20) |
输出 year_month_day 到流中 (函数模板) |
(C++20) |
输出 year_month_day_last 到流中 (函数模板) |
(C++20) |
输出 year_month_weekday 到流中 (函数模板) |
(C++20) |
输出 year_month_weekday_last 到流中 (函数模板) |
(C++20) |
输出 hh_mm_ss 到流中 (函数模板) |
(C++20) |
输出 sys_info 到流中 (函数模板) |
(C++20) |
输出 local_info 对象到流中 (函数模板) |
(C++20) |
输出 zoned_time 到流中 (函数模板) |
(C++20) |
按照提供的格式从流分析 day (函数模板) |
(C++20) |
按照提供的格式从流分析 month (函数模板) |
(C++20) |
按照提供的格式从流分析 year (函数模板) |
(C++20) |
按照提供的格式从流分析 weekday (函数模板) |
(C++20) |
按照提供的格式从流分析 month_day (函数模板) |
(C++20) |
按照提供的格式从流分析 year_month (函数模板) |
(C++20) |
按照给定的格式从流分析 year_month_day (函数模板) |
(C++20) |
从流分析 chrono 对象 (函数模板) |
字面量 | |
定义于内联命名空间
std::literals::chrono_literals | |
(C++14) |
表示小时的 std::chrono::duration 字面量 (函数) |
(C++14) |
表示分钟的 std::chrono::duration 字面量 (函数) |
(C++14) |
表示秒的 std::chrono::duration 字面量 (函数) |
(C++14) |
表示毫秒的 std::chrono::duration 字面量 (函数) |
(C++14) |
表示微秒的 std::chrono::duration 字面量 (函数) |
(C++14) |
表示纳秒的 std::chrono::duration 字面量 (函数) |
(C++20) |
表示月内日期的 std::chrono::day 字面量 (函数) |
(C++20) |
表示特定年的 std::chrono::year 字面量 (函数) |
概要
#include <compare> namespace std { namespace chrono { // 类模板 duration template<class Rep, class Period = ratio<1>> class duration; // 类模板 time_point template<class Clock, class Duration = typename Clock::duration> class time_point; } // common_type 特化 template<class Rep1, class Period1, class Rep2, class Period2> struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>; template<class Clock, class Duration1, class Duration2> struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>; namespace chrono { // 定制特征 template<class Rep> struct treat_as_floating_point; template<class Rep> inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<Rep>::value; template<class Rep> struct duration_values; template<class T> struct is_clock; template<class T> inline constexpr bool is_clock_v = is_clock<T>::value; // duration 算术 template<class Rep1, class Period1, class Rep2, class Period2> constexpr common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>> operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); template<class Rep1, class Period1, class Rep2, class Period2> constexpr common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>> operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); template<class Rep1, class Period, class Rep2> constexpr duration<common_type_t<Rep1, Rep2>, Period> operator*(const duration<Rep1, Period>& d, const Rep2& s); template<class Rep1, class Rep2, class Period> constexpr duration<common_type_t<Rep1, Rep2>, Period> operator*(const Rep1& s, const duration<Rep2, Period>& d); template<class Rep1, class Period, class Rep2> constexpr duration<common_type_t<Rep1, Rep2>, Period> operator/(const duration<Rep1, Period>& d, const Rep2& s); template<class Rep1, class Period1, class Rep2, class Period2> constexpr common_type_t<Rep1, Rep2> operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); template<class Rep1, class Period, class Rep2> constexpr duration<common_type_t<Rep1, Rep2>, Period> operator%(const duration<Rep1, Period>& d, const Rep2& s); template<class Rep1, class Period1, class Rep2, class Period2> constexpr common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>> operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); // duration 比较 template<class Rep1, class Period1, class Rep2, class Period2> constexpr bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); template<class Rep1, class Period1, class Rep2, class Period2> constexpr bool operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); template<class Rep1, class Period1, class Rep2, class Period2> constexpr bool operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); template<class Rep1, class Period1, class Rep2, class Period2> constexpr bool operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); template<class Rep1, class Period1, class Rep2, class Period2> constexpr bool operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); template<class Rep1, class Period1, class Rep2, class Period2> requires /* 见描述 */ constexpr auto operator<=>(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); // 转换 template<class ToDuration, class Rep, class Period> constexpr ToDuration duration_cast(const duration<Rep, Period>& d); template<class ToDuration, class Rep, class Period> constexpr ToDuration floor(const duration<Rep, Period>& d); template<class ToDuration, class Rep, class Period> constexpr ToDuration ceil(const duration<Rep, Period>& d); template<class ToDuration, class Rep, class Period> constexpr ToDuration round(const duration<Rep, Period>& d); // duration I/O template<class CharT, class Traits, class Rep, class Period> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const duration<Rep, Period>& d); template<class CharT, class Traits, class Rep, class Period, class Alloc = allocator<CharT>> basic_istream<CharT, Traits>& from_stream(basic_istream<CharT, Traits>& is, const CharT* fmt, duration<Rep, Period>& d, basic_string<CharT, Traits, Alloc>* abbrev = nullptr, minutes* offset = nullptr); // 便利 typedef using nanoseconds = duration</* 至少有 64 位的有符号整数类型 */, nano>; using microseconds = duration</* 至少有 55 位的有符号整数类型 */, micro>; using milliseconds = duration</* 至少有 45 位的有符号整数类型 */, milli>; using seconds = duration</* 至少有 35 位的有符号整数类型 */>; using minutes = duration</* 至少有 29 位的有符号整数类型 */, ratio< 60>>; using hours = duration</* 至少有 23 位的有符号整数类型 */, ratio<3600>>; using days = duration</* 至少有 25 位的有符号整数类型 */, ratio_multiply<ratio<24>, hours::period>>; using weeks = duration</* 至少有 22 位的有符号整数类型 */, ratio_multiply<ratio<7>, days::period>>; using years = duration</* 至少有 17 位的有符号整数类型 */, ratio_multiply<ratio<146097, 400>, days::period>>; using months = duration</* 至少有 20 位的有符号整数类型 */, ratio_divide<years::period, ratio<12>>>; // time_point 算术 template<class Clock, class Duration1, class Rep2, class Period2> constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>> operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs); template<class Rep1, class Period1, class Clock, class Duration2> constexpr time_point<Clock, common_type_t<duration<Rep1, Period1>, Duration2>> operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs); template<class Clock, class Duration1, class Rep2, class Period2> constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>> operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs); template<class Clock, class Duration1, class Duration2> constexpr common_type_t<Duration1, Duration2> operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); // time_point 比较 template<class Clock, class Duration1, class Duration2> constexpr bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); template<class Clock, class Duration1, class Duration2> constexpr bool operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); template<class Clock, class Duration1, class Duration2> constexpr bool operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); template<class Clock, class Duration1, class Duration2> constexpr bool operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); template<class Clock, class Duration1, class Duration2> constexpr bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); template<class Clock, class Duration1, three_way_comparable_with<Duration1> Duration2> constexpr auto operator<=>(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); // 转换 template<class ToDuration, class Clock, class Duration> constexpr time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t); template<class ToDuration, class Clock, class Duration> constexpr time_point<Clock, ToDuration> floor(const time_point<Clock, Duration>& tp); template<class ToDuration, class Clock, class Duration> constexpr time_point<Clock, ToDuration> ceil(const time_point<Clock, Duration>& tp); template<class ToDuration, class Clock, class Duration> constexpr time_point<Clock, ToDuration> round(const time_point<Clock, Duration>& tp); // 特化的算法 template<class Rep, class Period> constexpr duration<Rep, Period> abs(duration<Rep, Period> d); // 类 system_clock class system_clock; template<class Duration> using sys_time = time_point<system_clock, Duration>; using sys_seconds = sys_time<seconds>; using sys_days = sys_time<days>; template<class CharT, class Traits, class Duration> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const sys_time<Duration>& tp); template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const sys_days& dp); template<class CharT, class Traits, class Duration, class Alloc = allocator<CharT>> basic_istream<CharT, Traits>& from_stream(basic_istream<CharT, Traits>& is, const CharT* fmt, sys_time<Duration>& tp, basic_string<CharT, Traits, Alloc>* abbrev = nullptr, minutes* offset = nullptr); // 类 utc_clock class utc_clock; template<class Duration> using utc_time = time_point<utc_clock, Duration>; using utc_seconds = utc_time<seconds>; template<class CharT, class Traits, class Duration> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const utc_time<Duration>& t); template<class CharT, class Traits, class Duration, class Alloc = allocator<CharT>> basic_istream<CharT, Traits>& from_stream(basic_istream<CharT, Traits>& is, const CharT* fmt, utc_time<Duration>& tp, basic_string<CharT, Traits, Alloc>* abbrev = nullptr, minutes* offset = nullptr); struct leap_second_info; template<class Duration> leap_second_info get_leap_second_info(const utc_time<Duration>& ut); // 类 tai_clock class tai_clock; template<class Duration> using tai_time = time_point<tai_clock, Duration>; using tai_seconds = tai_time<seconds>; template<class CharT, class Traits, class Duration> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const tai_time<Duration>& t); template<class CharT, class Traits, class Duration, class Alloc = allocator<CharT>> basic_istream<CharT, Traits>& from_stream(basic_istream<CharT, Traits>& is, const CharT* fmt, tai_time<Duration>& tp, basic_string<CharT, Traits, Alloc>* abbrev = nullptr, minutes* offset = nullptr); // 类 gps_clock class gps_clock; template<class Duration> using gps_time = time_point<gps_clock, Duration>; using gps_seconds = gps_time<seconds>; template<class CharT, class Traits, class Duration> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const gps_time<Duration>& t); template<class CharT, class Traits, class Duration, class Alloc = allocator<CharT>> basic_istream<CharT, Traits>& from_stream(basic_istream<CharT, Traits>& is, const CharT* fmt, gps_time<Duration>& tp, basic_string<CharT, Traits, Alloc>* abbrev = nullptr, minutes* offset = nullptr); // 类型 file_clock using file_clock = /* 见描述 */; template<class Duration> using file_time = time_point<file_clock, Duration>; template<class CharT, class Traits, class Duration> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const file_time<Duration>& tp); template<class CharT, class Traits, class Duration, class Alloc = allocator<CharT>> basic_istream<CharT, Traits>& from_stream(basic_istream<CharT, Traits>& is, const CharT* fmt, file_time<Duration>& tp, basic_string<CharT, Traits, Alloc>* abbrev = nullptr, minutes* offset = nullptr); // 类 steady_clock class steady_clock; // 类 high_resolution_clock class high_resolution_clock; // 本地时间 struct local_t {}; template<class Duration> using local_time = time_point<local_t, Duration>; using local_seconds = local_time<seconds>; using local_days = local_time<days>; template<class CharT, class Traits, class Duration> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const local_time<Duration>& tp); template<class CharT, class Traits, class Duration, class Alloc = allocator<CharT>> basic_istream<CharT, Traits>& from_stream(basic_istream<CharT, Traits>& is, const CharT* fmt, local_time<Duration>& tp, basic_string<CharT, Traits, Alloc>* abbrev = nullptr, minutes* offset = nullptr); // time_point 转换 template<class DestClock, class SourceClock> struct clock_time_conversion; template<class DestClock, class SourceClock, class Duration> auto clock_cast(const time_point<SourceClock, Duration>& t); // 类 last_spec struct last_spec; // 类 day class day; constexpr bool operator==(const day& x, const day& y) noexcept; constexpr strong_ordering operator<=>(const day& x, const day& y) noexcept; constexpr day operator+(const day& x, const days& y) noexcept; constexpr day operator+(const days& x, const day& y) noexcept; constexpr day operator-(const day& x, const days& y) noexcept; constexpr days operator-(const day& x, const day& y) noexcept; template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const day& d); template<class CharT, class Traits, class Alloc = allocator<CharT>> basic_istream<CharT, Traits>& from_stream(basic_istream<CharT, Traits>& is, const CharT* fmt, day& d, basic_string<CharT, Traits, Alloc>* abbrev = nullptr, minutes* offset = nullptr); // 类 month class month; constexpr bool operator==(const month& x, const month& y) noexcept; constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept; constexpr month operator+(const month& x, const months& y) noexcept; constexpr month operator+(const months& x, const month& y) noexcept; constexpr month operator-(const month& x, const months& y) noexcept; constexpr months operator-(const month& x, const month& y) noexcept; template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const month& m); template<class CharT, class Traits, class Alloc = allocator<CharT>> basic_istream<CharT, Traits>& from_stream(basic_istream<CharT, Traits>& is, const CharT* fmt, month& m, basic_string<CharT, Traits, Alloc>* abbrev = nullptr, minutes* offset = nullptr); // 类 year class year; constexpr bool operator==(const year& x, const year& y) noexcept; constexpr strong_ordering operator<=>(const year& x, const year& y) noexcept; constexpr year operator+(const year& x, const years& y) noexcept; constexpr year operator+(const years& x, const year& y) noexcept; constexpr year operator-(const year& x, const years& y) noexcept; constexpr years operator-(const year& x, const year& y) noexcept; template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const year& y); template<class CharT, class Traits, class Alloc = allocator<CharT>> basic_istream<CharT, Traits>& from_stream(basic_istream<CharT, Traits>& is, const CharT* fmt, year& y, basic_string<CharT, Traits, Alloc>* abbrev = nullptr, minutes* offset = nullptr); // 类 weekday class weekday; constexpr bool operator==(const weekday& x, const weekday& y) noexcept; constexpr weekday operator+(const weekday& x, const days& y) noexcept; constexpr weekday operator+(const days& x, const weekday& y) noexcept; constexpr weekday operator-(const weekday& x, const days& y) noexcept; constexpr days operator-(const weekday& x, const weekday& y) noexcept; template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const weekday& wd); template<class CharT, class Traits, class Alloc = allocator<CharT>> basic_istream<CharT, Traits>& from_stream(basic_istream<CharT, Traits>& is, const CharT* fmt, weekday& wd, basic_string<CharT, Traits, Alloc>* abbrev = nullptr, minutes* offset = nullptr); // 类 weekday_indexed class weekday_indexed; constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept; template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const weekday_indexed& wdi); // 类 weekday_last class weekday_last; constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept; template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const weekday_last& wdl); // 类 month_day class month_day; constexpr bool operator==(const month_day& x, const month_day& y) noexcept; constexpr strong_ordering operator<=>(const month_day& x, const month_day& y) noexcept; template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const month_day& md); template<class CharT, class Traits, class Alloc = allocator<CharT>> basic_istream<CharT, Traits>& from_stream(basic_istream<CharT, Traits>& is, const CharT* fmt, month_day& md, basic_string<CharT, Traits, Alloc>* abbrev = nullptr, minutes* offset = nullptr); // 类 month_day_last class month_day_last; constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept; constexpr strong_ordering operator<=>(const month_day_last& x, const month_day_last& y) noexcept; template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const month_day_last& mdl); // 类 month_weekday class month_weekday; constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept; template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const month_weekday& mwd); // 类 month_weekday_last class month_weekday_last; constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept; template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const month_weekday_last& mwdl); // 类 year_month class year_month; constexpr bool operator==(const year_month& x, const year_month& y) noexcept; constexpr strong_ordering operator<=>(const year_month& x, const year_month& y) noexcept; constexpr year_month operator+(const year_month& ym, const months& dm) noexcept; constexpr year_month operator+(const months& dm, const year_month& ym) noexcept; constexpr year_month operator-(const year_month& ym, const months& dm) noexcept; constexpr months operator-(const year_month& x, const year_month& y) noexcept; constexpr year_month operator+(const year_month& ym, const years& dy) noexcept; constexpr year_month operator+(const years& dy, const year_month& ym) noexcept; constexpr year_month operator-(const year_month& ym, const years& dy) noexcept; template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const year_month& ym); template<class CharT, class Traits, class Alloc = allocator<CharT>> basic_istream<CharT, Traits>& from_stream(basic_istream<CharT, Traits>& is, const CharT* fmt, year_month& ym, basic_string<CharT, Traits, Alloc>* abbrev = nullptr, minutes* offset = nullptr); // 类 year_month_day class year_month_day; constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept; constexpr strong_ordering operator<=>(const year_month_day& x, const year_month_day& y) noexcept; constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept; constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept; constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept; constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept; constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept; constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept; template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const year_month_day& ymd); template<class CharT, class Traits, class Alloc = allocator<CharT>> basic_istream<CharT, Traits>& from_stream(basic_istream<CharT, Traits>& is, const CharT* fmt, year_month_day& ymd, basic_string<CharT, Traits, Alloc>* abbrev = nullptr, minutes* offset = nullptr); // 类 year_month_day_last class year_month_day_last; constexpr bool operator==(const year_month_day_last& x, const year_month_day_last& y) noexcept; constexpr strong_ordering operator<=>(const year_month_day_last& x, const year_month_day_last& y) noexcept; constexpr year_month_day_last operator+(const year_month_day_last& ymdl, const months& dm) noexcept; constexpr year_month_day_last operator+(const months& dm, const year_month_day_last& ymdl) noexcept; constexpr year_month_day_last operator+(const year_month_day_last& ymdl, const years& dy) noexcept; constexpr year_month_day_last operator+(const years& dy, const year_month_day_last& ymdl) noexcept; constexpr year_month_day_last operator-(const year_month_day_last& ymdl, const months& dm) noexcept; constexpr year_month_day_last operator-(const year_month_day_last& ymdl, const years& dy) noexcept; template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const year_month_day_last& ymdl); // 类 year_month_weekday class year_month_weekday; constexpr bool operator==(const year_month_weekday& x, const year_month_weekday& y) noexcept; constexpr year_month_weekday operator+(const year_month_weekday& ymwd, const months& dm) noexcept; constexpr year_month_weekday operator+(const months& dm, const year_month_weekday& ymwd) noexcept; constexpr year_month_weekday operator+(const year_month_weekday& ymwd, const years& dy) noexcept; constexpr year_month_weekday operator+(const years& dy, const year_month_weekday& ymwd) noexcept; constexpr year_month_weekday operator-(const year_month_weekday& ymwd, const months& dm) noexcept; constexpr year_month_weekday operator-(const year_month_weekday& ymwd, const years& dy) noexcept; template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const year_month_weekday& ymwdi); // 类 year_month_weekday_last class year_month_weekday_last; constexpr bool operator==(const year_month_weekday_last& x, const year_month_weekday_last& y) noexcept; constexpr year_month_weekday_last operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept; constexpr year_month_weekday_last operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept; constexpr year_month_weekday_last operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept; constexpr year_month_weekday_last operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept; constexpr year_month_weekday_last operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept; constexpr year_month_weekday_last operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept; template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const year_month_weekday_last& ymwdl); // 公历约定语法运算符 constexpr year_month operator/(const year& y, const month& m) noexcept; constexpr year_month operator/(const year& y, int m) noexcept; constexpr month_day operator/(const month& m, const day& d) noexcept; constexpr month_day operator/(const month& m, int d) noexcept; constexpr month_day operator/(int m, const day& d) noexcept; constexpr month_day operator/(const day& d, const month& m) noexcept; constexpr month_day operator/(const day& d, int m) noexcept; constexpr month_day_last operator/(const month& m, last_spec) noexcept; constexpr month_day_last operator/(int m, last_spec) noexcept; constexpr month_day_last operator/(last_spec, const month& m) noexcept; constexpr month_day_last operator/(last_spec, int m) noexcept; constexpr month_weekday operator/(const month& m, const weekday_indexed& wdi) noexcept; constexpr month_weekday operator/(int m, const weekday_indexed& wdi) noexcept; constexpr month_weekday operator/(const weekday_indexed& wdi, const month& m) noexcept; constexpr month_weekday operator/(const weekday_indexed& wdi, int m) noexcept; constexpr month_weekday_last operator/(const month& m, const weekday_last& wdl) noexcept; constexpr month_weekday_last operator/(int m, const weekday_last& wdl) noexcept; constexpr month_weekday_last operator/(const weekday_last& wdl, const month& m) noexcept; constexpr month_weekday_last operator/(const weekday_last& wdl, int m) noexcept; constexpr year_month_day operator/(const year_month& ym, const day& d) noexcept; constexpr year_month_day operator/(const year_month& ym, int d) noexcept; constexpr year_month_day operator/(const year& y, const month_day& md) noexcept; constexpr year_month_day operator/(int y, const month_day& md) noexcept; constexpr year_month_day operator/(const month_day& md, const year& y) noexcept; constexpr year_month_day operator/(const month_day& md, int y) noexcept; constexpr year_month_day_last operator/(const year_month& ym, last_spec) noexcept; constexpr year_month_day_last operator/(const year& y, const month_day_last& mdl) noexcept; constexpr year_month_day_last operator/(int y, const month_day_last& mdl) noexcept; constexpr year_month_day_last operator/(const month_day_last& mdl, const year& y) noexcept; constexpr year_month_day_last operator/(const month_day_last& mdl, int y) noexcept; constexpr year_month_weekday operator/(const year_month& ym, const weekday_indexed& wdi) noexcept; constexpr year_month_weekday operator/(const year& y, const month_weekday& mwd) noexcept; constexpr year_month_weekday operator/(int y, const month_weekday& mwd) noexcept; constexpr year_month_weekday operator/(const month_weekday& mwd, const year& y) noexcept; constexpr year_month_weekday operator/(const month_weekday& mwd, int y) noexcept; constexpr year_month_weekday_last operator/(const year_month& ym, const weekday_last& wdl) noexcept; constexpr year_month_weekday_last operator/(const year& y, const month_weekday_last& mwdl) noexcept; constexpr year_month_weekday_last operator/(int y, const month_weekday_last& mwdl) noexcept; constexpr year_month_weekday_last operator/(const month_weekday_last& mwdl, const year& y) noexcept; constexpr year_month_weekday_last operator/(const month_weekday_last& mwdl, int y) noexcept; // 类模板 hh_mm_ss template<class Duration> class hh_mm_ss; template<class CharT, class Traits, class Duration> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const hh_mm_ss<Duration>& hms); // 12/24 时制函数 constexpr bool is_am(const hours& h) noexcept; constexpr bool is_pm(const hours& h) noexcept; constexpr hours make12(const hours& h) noexcept; constexpr hours make24(const hours& h, bool is_pm) noexcept; // 时区数据库 struct tzdb; class tzdb_list; // 时区数据库访问 const tzdb& get_tzdb(); tzdb_list& get_tzdb_list(); const time_zone* locate_zone(string_view tz_name); const time_zone* current_zone(); // 远程时区数据库支持 const tzdb& reload_tzdb(); string remote_version(); // 异常类 class nonexistent_local_time; class ambiguous_local_time; // 信息类 struct sys_info; template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const sys_info& si); struct local_info; template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const local_info& li); // 类 time_zone enum class choose {earliest, latest}; class time_zone; bool operator==(const time_zone& x, const time_zone& y) noexcept; strong_ordering operator<=>(const time_zone& x, const time_zone& y) noexcept; // 类模板 zoned_traits template<class T> struct zoned_traits; // 类模板 zoned_time template<class Duration, class TimeZonePtr = const time_zone*> class zoned_time; using zoned_seconds = zoned_time<seconds>; template<class Duration1, class Duration2, class TimeZonePtr> bool operator==(const zoned_time<Duration1, TimeZonePtr>& x, const zoned_time<Duration2, TimeZonePtr>& y); template<class CharT, class Traits, class Duration, class TimeZonePtr> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os, const zoned_time<Duration, TimeZonePtr>& t); // 闰秒支持 class leap_second; bool operator==(const leap_second& x, const leap_second& y); strong_ordering operator<=>(const leap_second& x, const leap_second& y); template<class Duration> constexpr bool operator==(const leap_second& x, const sys_time<Duration>& y); template<class Duration> constexpr bool operator< (const leap_second& x, const sys_time<Duration>& y); template<class Duration> constexpr bool operator< (const sys_time<Duration>& x, const leap_second& y); template<class Duration> constexpr bool operator> (const leap_second& x, const sys_time<Duration>& y); template<class Duration> constexpr bool operator> (const sys_time<Duration>& x, const leap_second& y); template<class Duration> constexpr bool operator<=(const leap_second& x, const sys_time<Duration>& y); template<class Duration> constexpr bool operator<=(const sys_time<Duration>& x, const leap_second& y); template<class Duration> constexpr bool operator>=(const leap_second& x, const sys_time<Duration>& y); template<class Duration> constexpr bool operator>=(const sys_time<Duration>& x, const leap_second& y); template<class Duration> requires three_way_comparable_with<sys_seconds, sys_time<Duration>> constexpr auto operator<=>(const leap_second& x, const sys_time<Duration>& y); // 类 time_zone_link class time_zone_link; bool operator==(const time_zone_link& x, const time_zone_link& y); strong_ordering operator<=>(const time_zone_link& x, const time_zone_link& y); // formatting template<class Duration> struct /*local-time-format-t*/; // 仅用于阐释 template<class Duration> /*local-time-format-t*/<Duration> local_time_format(local_time<Duration> time, const string* abbrev = nullptr, const seconds* offset_sec = nullptr); } template<class Rep, class Period, class CharT> struct formatter<chrono::duration<Rep, Period>, CharT>; template<class Duration, class CharT> struct formatter<chrono::sys_time<Duration>, CharT>; template<class Duration, class CharT> struct formatter<chrono::utc_time<Duration>, CharT>; template<class Duration, class CharT> struct formatter<chrono::tai_time<Duration>, CharT>; template<class Duration, class CharT> struct formatter<chrono::gps_time<Duration>, CharT>; template<class Duration, class CharT> struct formatter<chrono::file_time<Duration>, CharT>; template<class Duration, class CharT> struct formatter<chrono::local_time<Duration>, CharT>; template<class Duration, class CharT> struct formatter<chrono::/*local-time-format-t*/<Duration>, CharT>; template<class CharT> struct formatter<chrono::day, CharT>; template<class CharT> struct formatter<chrono::month, CharT>; template<class CharT> struct formatter<chrono::year, CharT>; template<class CharT> struct formatter<chrono::weekday, CharT>; template<class CharT> struct formatter<chrono::weekday_indexed, CharT>; template<class CharT> struct formatter<chrono::weekday_last, CharT>; template<class CharT> struct formatter<chrono::month_day, CharT>; template<class CharT> struct formatter<chrono::month_day_last, CharT>; template<class CharT> struct formatter<chrono::month_weekday, CharT>; template<class CharT> struct formatter<chrono::month_weekday_last, CharT>; template<class CharT> struct formatter<chrono::year_month, CharT>; template<class CharT> struct formatter<chrono::year_month_day, CharT>; template<class CharT> struct formatter<chrono::year_month_day_last, CharT>; template<class CharT> struct formatter<chrono::year_month_weekday, CharT>; template<class CharT> struct formatter<chrono::year_month_weekday_last, CharT>; template<class Rep, class Period, class CharT> struct formatter<chrono::hh_mm_ss<duration<Rep, Period>>, CharT>; template<class CharT> struct formatter<chrono::sys_info, CharT>; template<class CharT> struct formatter<chrono::local_info, CharT>; template<class Duration, class TimeZonePtr, class CharT> struct formatter<chrono::zoned_time<Duration, TimeZonePtr>, CharT>; namespace chrono { // 分析 template<class charT, class Parsable> /* 未指明 */ parse(const charT* fmt, Parsable& tp); template<class CharT, class Traits, class Alloc, class Parsable> /* 未指明 */ parse(const basic_string<CharT, Traits, Alloc>& format, Parsable& tp); template<class charT, class traits, class Alloc, class Parsable> /* 未指明 */ parse(const charT* fmt, Parsable& tp, basic_string<charT, traits, Alloc>& abbrev); template<class CharT, class Traits, class Alloc, class Parsable> /* 未指明 */ parse(const basic_string<CharT, Traits, Alloc>& format, Parsable& tp, basic_string<CharT, Traits, Alloc>& abbrev); template<class charT, class Parsable> /* 未指明 */ parse(const charT* fmt, Parsable& tp, minutes& offset); template<class CharT, class Traits, class Alloc, class Parsable> /* 未指明 */ parse(const basic_string<CharT, Traits, Alloc>& format, Parsable& tp, minutes& offset); template<class charT, class traits, class Alloc, class Parsable> /* 未指明 */ parse(const charT* fmt, Parsable& tp, basic_string<charT, traits, Alloc>& abbrev, minutes& offset); template<class CharT, class Traits, class Alloc, class Parsable> /* 未指明 */ parse(const basic_string<CharT, Traits, Alloc>& format, Parsable& tp, basic_string<CharT, Traits, Alloc>& abbrev, minutes& offset); // 日历常量 inline constexpr last_spec last{}; inline constexpr weekday Sunday{0}; inline constexpr weekday Monday{1}; inline constexpr weekday Tuesday{2}; inline constexpr weekday Wednesday{3}; inline constexpr weekday Thursday{4}; inline constexpr weekday Friday{5}; inline constexpr weekday Saturday{6}; inline constexpr month January{1}; inline constexpr month February{2}; inline constexpr month March{3}; inline constexpr month April{4}; inline constexpr month May{5}; inline constexpr month June{6}; inline constexpr month July{7}; inline constexpr month August{8}; inline constexpr month September{9}; inline constexpr month October{10}; inline constexpr month November{11}; inline constexpr month December{12}; } inline namespace literals { inline namespace chrono_literals { // suffixes for duration literals constexpr chrono::hours operator""h(unsigned long long); constexpr chrono::duration</* 未指明 */, ratio<3600, 1>> operator""h(long double); constexpr chrono::minutes operator""min(unsigned long long); constexpr chrono::duration</* 未指明 */, ratio<60, 1>> operator""min(long double); constexpr chrono::seconds operator""s(unsigned long long); constexpr chrono::duration</* 未指明 */> operator""s(long double); constexpr chrono::milliseconds operator""ms(unsigned long long); constexpr chrono::duration</* 未指明 */, milli> operator""ms(long double); constexpr chrono::microseconds operator""us(unsigned long long); constexpr chrono::duration</* 未指明 */, micro> operator""us(long double); constexpr chrono::nanoseconds operator""ns(unsigned long long); constexpr chrono::duration</* 未指明 */, nano> operator""ns(long double); // 非成员函数 constexpr chrono::day operator""d(unsigned long long d) noexcept; // 非成员函数 constexpr chrono::year operator""y(unsigned long long y) noexcept; } } namespace chrono { using namespace literals::chrono_literals; } }
类模板 std::chrono::duration
namespace std::chrono { template<class Rep, class Period = ratio<1>> class duration { public: using rep = Rep; using period = typename Period::type; private: rep rep_; // 仅用于阐释 public: // 构造/复制/销毁 constexpr duration() = default; template<class Rep2> constexpr explicit duration(const Rep2& r); template<class Rep2, class Period2> constexpr duration(const duration<Rep2, Period2>& d); ~duration() = default; duration(const duration&) = default; duration& operator=(const duration&) = default; // 观察器 constexpr rep count() const; // 算术 constexpr common_type_t<duration> operator+() const; constexpr common_type_t<duration> operator-() const; constexpr duration& operator++(); constexpr duration operator++(int); constexpr duration& operator--(); constexpr duration operator--(int); constexpr duration& operator+=(const duration& d); constexpr duration& operator-=(const duration& d); constexpr duration& operator*=(const rep& rhs); constexpr duration& operator/=(const rep& rhs); constexpr duration& operator%=(const rep& rhs); constexpr duration& operator%=(const duration& rhs); // 特殊值 static constexpr duration zero() noexcept; static constexpr duration min() noexcept; static constexpr duration max() noexcept; }; }
类模板 std::chrono::time_point
namespace std::chrono { template<class Clock, class Duration = typename Clock::duration> class time_point { public: using clock = Clock; using duration = Duration; using rep = typename duration::rep; using period = typename duration::period; private: duration d_; // 仅用于阐释 public: // 构造 constexpr time_point(); // 拥有纪元值 constexpr explicit time_point(const duration& d); // 同 time_point() + d template<class Duration2> constexpr time_point(const time_point<clock, Duration2>& t); // 观察器 constexpr duration time_since_epoch() const; // 算术 constexpr time_point& operator++(); constexpr time_point operator++(int); constexpr time_point& operator--(); constexpr time_point operator--(int); constexpr time_point& operator+=(const duration& d); constexpr time_point& operator-=(const duration& d); // 特殊值 static constexpr time_point min() noexcept; static constexpr time_point max() noexcept; }; }
类模板 std::common_type 对 std::chrono::duration 的特化
namespace std { template<class Rep1, class Period1, class Rep2, class Period2> struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>> { using type = chrono::duration<common_type_t<Rep1, Rep2>, /* 见描述 */>; }; }
类模板 std::common_type 对 std::chrono::time_point 的特化
namespace std { template<class Clock, class Duration1, class Duration2> struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>> { using type = chrono::time_point<Clock, common_type_t<Duration1, Duration2>>; }; }
类模板 std::chrono::treat_as_floating_point
template<class Rep> struct treat_as_floating_point : is_floating_point<Rep> { };
类模板 std::chrono::duration_values
namespace std::chrono { template<class Rep> struct duration_values { public: static constexpr Rep zero() noexcept; static constexpr Rep min() noexcept; static constexpr Rep max() noexcept; }; }
类 std::chrono::system_clock
namespace std::chrono { class system_clock { public: using rep = /* 见描述 */; using period = ratio</* 未指明 */, /* 未指明 */>; using duration = chrono::duration<rep, period>; using time_point = chrono::time_point<system_clock>; static constexpr bool is_steady = /* 未指明 */; static time_point now() noexcept; // 映射到/自 C 类型 time_t static time_t to_time_t (const time_point& t) noexcept; static time_point from_time_t(time_t t) noexcept; }; }
类 std::chrono::utc_clock
namespace std::chrono { class utc_clock { public: using rep = /* 有符号算术类型 */; using period = ratio</* 未指明 */, /* 未指明 */>; using duration = chrono::duration<rep, period>; using time_point = chrono::time_point<utc_clock>; static constexpr bool is_steady = /* 未指明 */; static time_point now(); template<class Duration> static sys_time<common_type_t<Duration, seconds>> to_sys(const utc_time<Duration>& t); template<class Duration> static utc_time<common_type_t<Duration, seconds>> from_sys(const sys_time<Duration>& t); }; }
类 std::chrono::tai_clock
namespace std::chrono { class tai_clock { public: using rep = /* 有符号算术类型 */; using period = ratio</* 未指明 */, /* 未指明 */>; using duration = chrono::duration<rep, period>; using time_point = chrono::time_point<tai_clock>; static constexpr bool is_steady = /* 未指明 */; static time_point now(); template<class Duration> static sys_time<common_type_t<Duration, seconds>> to_sys(const tai_time<Duration>& t); template<class Duration> static tai_time<common_type_t<Duration, seconds>> from_sys(const sys_time<Duration>& t); }; }
类 std::chrono::gps_clock
namespace std::chrono { class gps_clock { public: using rep = /* 有符号算术类型 */; using period = ratio</* 未指明 */, /* 未指明 */>; using duration = chrono::duration<rep, period>; using time_point = chrono::time_point<gps_clock>; static constexpr bool is_steady = /* 未指明 */; static time_point now(); template<class Duration> static sys_time<common_type_t<Duration, seconds>> to_sys(const gps_time<Duration>& t); template<class Duration> static gps_time<common_type_t<Duration, seconds>> from_sys(const sys_time<Duration>& t); }; }
类 std::chrono::steady_clock
namespace std::chrono { class steady_clock { public: using rep = /* 未指明 */; using period = ratio</* 未指明 */, /* 未指明 */>; using duration = chrono::duration<rep, period>; using time_point = chrono::time_point</* 未指明 */, duration>; static constexpr bool is_steady = true; static time_point now() noexcept; }; }
类 std::chrono::high_resolution_clock
namespace std::chrono { class high_resolution_clock { public: using rep = /* 未指明 */; using period = ratio</* 未指明 */, /* 未指明 */>; using duration = chrono::duration<rep, period>; using time_point = chrono::time_point</* 未指明 */, duration>; static constexpr bool is_steady = /* 未指明 */; static time_point now() noexcept; }; }
类模板 std::chrono::clock_time_conversion
namespace std::chrono { template<class DestClock, class SourceClock> struct clock_time_conversion {}; template<class Clock> struct clock_time_conversion<Clock, Clock> { template<class Duration> time_point<Clock, Duration> operator()(const time_point<Clock, Duration>& t) const; }; template<> struct clock_time_conversion<system_clock, system_clock> { template<class Duration> sys_time<Duration> operator()(const sys_time<Duration>& t) const; }; template<> struct clock_time_conversion<utc_clock, utc_clock> { template<class Duration> utc_time<Duration> operator()(const utc_time<Duration>& t) const; }; template<> struct clock_time_conversion<utc_clock, system_clock> { template<class Duration> utc_time<common_type_t<Duration, seconds>> operator()(const sys_time<Duration>& t) const; }; template<> struct clock_time_conversion<system_clock, utc_clock> { template<class Duration> sys_time<common_type_t<Duration, seconds>> operator()(const utc_time<Duration>& t) const; }; template<class SourceClock> struct clock_time_conversion<system_clock, SourceClock> { template<class Duration> auto operator()(const time_point<SourceClock, Duration>& t) const -> decltype(SourceClock::to_sys(t)); }; template<class DestClock> struct clock_time_conversion<DestClock, system_clock> { template<class Duration> auto operator()(const sys_time<Duration>& t) const -> decltype(DestClock::from_sys(t)); }; template<class SourceClock> struct clock_time_conversion<utc_clock, SourceClock> { template<class Duration> auto operator()(const time_point<SourceClock, Duration>& t) const -> decltype(SourceClock::to_utc(t)); }; template<class DestClock> struct clock_time_conversion<DestClock, utc_clock> { template<class Duration> auto operator()(const utc_time<Duration>& t) const -> decltype(DestClock::from_utc(t)); }; }
类 std::chrono::last_spec
namespace std::chrono { struct last_spec { explicit last_spec() = default; }; }
类 std::chrono::day
namespace std::chrono { class day { unsigned char d_; // 仅用于阐释 public: day() = default; constexpr explicit day(unsigned d) noexcept; constexpr day& operator++() noexcept; constexpr day operator++(int) noexcept; constexpr day& operator--() noexcept; constexpr day operator--(int) noexcept; constexpr day& operator+=(const days& d) noexcept; constexpr day& operator-=(const days& d) noexcept; constexpr explicit operator unsigned() const noexcept; constexpr bool ok() const noexcept; }; }
类 std::chrono::month
namespace std::chrono { class month { unsigned char m_; // 仅用于阐释 public: month() = default; constexpr explicit month(unsigned m) noexcept; constexpr month& operator++() noexcept; constexpr month operator++(int) noexcept; constexpr month& operator--() noexcept; constexpr month operator--(int) noexcept; constexpr month& operator+=(const months& m) noexcept; constexpr month& operator-=(const months& m) noexcept; constexpr explicit operator unsigned() const noexcept; constexpr bool ok() const noexcept; }; }
类 std::chrono::year
namespace std::chrono { class year { short y_; // 仅用于阐释 public: year() = default; constexpr explicit year(int y) noexcept; constexpr year& operator++() noexcept; constexpr year operator++(int) noexcept; constexpr year& operator--() noexcept; constexpr year operator--(int) noexcept; constexpr year& operator+=(const years& y) noexcept; constexpr year& operator-=(const years& y) noexcept; constexpr year operator+() const noexcept; constexpr year operator-() const noexcept; constexpr bool is_leap() const noexcept; constexpr explicit operator int() const noexcept; constexpr bool ok() const noexcept; static constexpr year min() noexcept; static constexpr year max() noexcept; }; }
类 std::chrono::weekday
namespace std::chrono { class weekday { unsigned char wd_; // 仅用于阐释 public: weekday() = default; constexpr explicit weekday(unsigned wd) noexcept; constexpr weekday(const sys_days& dp) noexcept; constexpr explicit weekday(const local_days& dp) noexcept; constexpr weekday& operator++() noexcept; constexpr weekday operator++(int) noexcept; constexpr weekday& operator--() noexcept; constexpr weekday operator--(int) noexcept; constexpr weekday& operator+=(const days& d) noexcept; constexpr weekday& operator-=(const days& d) noexcept; constexpr unsigned c_encoding() const noexcept; constexpr unsigned iso_encoding() const noexcept; constexpr bool ok() const noexcept; constexpr weekday_indexed operator[](unsigned index) const noexcept; constexpr weekday_last operator[](last_spec) const noexcept; }; }
类 std::chrono::weekday_indexed
namespace std::chrono { class weekday_indexed { chrono::weekday wd_; // 仅用于阐释 unsigned char index_; // 仅用于阐释 public: weekday_indexed() = default; constexpr weekday_indexed(const chrono::weekday& wd, unsigned index) noexcept; constexpr chrono::weekday weekday() const noexcept; constexpr unsigned index() const noexcept; constexpr bool ok() const noexcept; }; }
类 std::chrono::weekday_last
namespace std::chrono { class weekday_last { chrono::weekday wd_; // 仅用于阐释 public: constexpr explicit weekday_last(const chrono::weekday& wd) noexcept; constexpr chrono::weekday weekday() const noexcept; constexpr bool ok() const noexcept; }; }
类 std::chrono::month_day
namespace std::chrono { class month_day { chrono::month m_; // 仅用于阐释 chrono::day d_; // 仅用于阐释 public: month_day() = default; constexpr month_day(const chrono::month& m, const chrono::day& d) noexcept; constexpr chrono::month month() const noexcept; constexpr chrono::day day() const noexcept; constexpr bool ok() const noexcept; }; }
类 std::chrono::month_day_last
namespace std::chrono { class month_day_last { chrono::month m_; // 仅用于阐释 public: constexpr explicit month_day_last(const chrono::month& m) noexcept; constexpr chrono::month month() const noexcept; constexpr bool ok() const noexcept; }; }
类 std::chrono::month_weekday
namespace std::chrono { class month_weekday { chrono::month m_; // 仅用于阐释 chrono::weekday_indexed wdi_; // 仅用于阐释 public: constexpr month_weekday(const chrono::month& m, const chrono::weekday_indexed& wdi) noexcept; constexpr chrono::month month() const noexcept; constexpr chrono::weekday_indexed weekday_indexed() const noexcept; constexpr bool ok() const noexcept; }; }
类 std::chrono::month_weekday_last
namespace std::chrono { class month_weekday_last { chrono::month m_; // 仅用于阐释 chrono::weekday_last wdl_; // 仅用于阐释 public: constexpr month_weekday_last(const chrono::month& m, const chrono::weekday_last& wdl) noexcept; constexpr chrono::month month() const noexcept; constexpr chrono::weekday_last weekday_last() const noexcept; constexpr bool ok() const noexcept; }; }
类 std::chrono::year_month
namespace std::chrono { class year_month { chrono::year y_; // 仅用于阐释 chrono::month m_; // 仅用于阐释 public: year_month() = default; constexpr year_month(const chrono::year& y, const chrono::month& m) noexcept; constexpr chrono::year year() const noexcept; constexpr chrono::month month() const noexcept; constexpr year_month& operator+=(const months& dm) noexcept; constexpr year_month& operator-=(const months& dm) noexcept; constexpr year_month& operator+=(const years& dy) noexcept; constexpr year_month& operator-=(const years& dy) noexcept; constexpr bool ok() const noexcept; }; }
类 std::chrono::year_month_day
namespace std::chrono { class year_month_day { chrono::year y_; // 仅用于阐释 chrono::month m_; // 仅用于阐释 chrono::day d_; // 仅用于阐释 public: year_month_day() = default; constexpr year_month_day(const chrono::year& y, const chrono::month& m, const chrono::day& d) noexcept; constexpr year_month_day(const year_month_day_last& ymdl) noexcept; constexpr year_month_day(const sys_days& dp) noexcept; constexpr explicit year_month_day(const local_days& dp) noexcept; constexpr year_month_day& operator+=(const months& m) noexcept; constexpr year_month_day& operator-=(const months& m) noexcept; constexpr year_month_day& operator+=(const years& y) noexcept; constexpr year_month_day& operator-=(const years& y) noexcept; constexpr chrono::year year() const noexcept; constexpr chrono::month month() const noexcept; constexpr chrono::day day() const noexcept; constexpr operator sys_days() const noexcept; constexpr explicit operator local_days() const noexcept; constexpr bool ok() const noexcept; }; }
类 std::chrono::year_month_day_last
namespace std::chrono { class year_month_day_last { chrono::year y_; // 仅用于阐释 chrono::month_day_last mdl_; // 仅用于阐释 public: constexpr year_month_day_last(const chrono::year& y, const chrono::month_day_last& mdl) noexcept; constexpr year_month_day_last& operator+=(const months& m) noexcept; constexpr year_month_day_last& operator-=(const months& m) noexcept; constexpr year_month_day_last& operator+=(const years& y) noexcept; constexpr year_month_day_last& operator-=(const years& y) noexcept; constexpr chrono::year year() const noexcept; constexpr chrono::month month() const noexcept; constexpr chrono::month_day_last month_day_last() const noexcept; constexpr chrono::day day() const noexcept; constexpr operator sys_days() const noexcept; constexpr explicit operator local_days() const noexcept; constexpr bool ok() const noexcept; }; }
类 std::chrono::year_month_weekday
namespace std::chrono { class year_month_weekday { chrono::year y_; // 仅用于阐释 chrono::month m_; // 仅用于阐释 chrono::weekday_indexed wdi_; // 仅用于阐释 public: year_month_weekday() = default; constexpr year_month_weekday(const chrono::year& y, const chrono::month& m, const chrono::weekday_indexed& wdi) noexcept; constexpr year_month_weekday(const sys_days& dp) noexcept; constexpr explicit year_month_weekday(const local_days& dp) noexcept; constexpr year_month_weekday& operator+=(const months& m) noexcept; constexpr year_month_weekday& operator-=(const months& m) noexcept; constexpr year_month_weekday& operator+=(const years& y) noexcept; constexpr year_month_weekday& operator-=(const years& y) noexcept; constexpr chrono::year year() const noexcept; constexpr chrono::month month() const noexcept; constexpr chrono::weekday weekday() const noexcept; constexpr unsigned index() const noexcept; constexpr chrono::weekday_indexed weekday_indexed() const noexcept; constexpr operator sys_days() const noexcept; constexpr explicit operator local_days() const noexcept; constexpr bool ok() const noexcept; }; }
类 std::chrono::year_month_weekday_last
namespace std::chrono { class year_month_weekday_last { chrono::year y_; // 仅用于阐释 chrono::month m_; // 仅用于阐释 chrono::weekday_last wdl_; // 仅用于阐释 public: constexpr year_month_weekday_last(const chrono::year& y, const chrono::month& m, const chrono::weekday_last& wdl) noexcept; constexpr year_month_weekday_last& operator+=(const months& m) noexcept; constexpr year_month_weekday_last& operator-=(const months& m) noexcept; constexpr year_month_weekday_last& operator+=(const years& y) noexcept; constexpr year_month_weekday_last& operator-=(const years& y) noexcept; constexpr chrono::year year() const noexcept; constexpr chrono::month month() const noexcept; constexpr chrono::weekday weekday() const noexcept; constexpr chrono::weekday_last weekday_last() const noexcept; constexpr operator sys_days() const noexcept; constexpr explicit operator local_days() const noexcept; constexpr bool ok() const noexcept; }; }
类模板 std::chrono::hh_mm_ss
namespace std::chrono { template<class Duration> class hh_mm_ss { public: static constexpr unsigned fractional_width = /* 见描述 */; using precision = /* 见描述 */; constexpr hh_mm_ss() noexcept : hh_mm_ss{Duration::zero()} {} constexpr explicit hh_mm_ss(Duration d); constexpr bool is_negative() const noexcept; constexpr chrono::hours hours() const noexcept; constexpr chrono::minutes minutes() const noexcept; constexpr chrono::seconds seconds() const noexcept; constexpr precision subseconds() const noexcept; constexpr explicit operator precision() const noexcept; constexpr precision to_duration() const noexcept; private: bool is_neg; // 仅用于阐释 chrono::hours h; // 仅用于阐释 chrono::minutes m; // 仅用于阐释 chrono::seconds s; // 仅用于阐释 precision ss; // 仅用于阐释 }; }
类 std::chrono::tzdb
namespace std::chrono { struct tzdb { string version; vector<time_zone> zones; vector<time_zone_link> links; vector<leap_second> leap_seconds; const time_zone* locate_zone(string_view tz_name) const; const time_zone* current_zone() const; }; }
类 std::chrono::tzdb_list
namespace std::chrono { class tzdb_list { public: tzdb_list(const tzdb_list&) = delete; tzdb_list& operator=(const tzdb_list&) = delete; // 未指明的额外构造函数 class const_iterator; const tzdb& front() const noexcept; const_iterator erase_after(const_iterator p); const_iterator begin() const noexcept; const_iterator end() const noexcept; const_iterator cbegin() const noexcept; const_iterator cend() const noexcept; }; }
类 std::chrono::nonexistent_local_time
namespace std::chrono { class nonexistent_local_time : public runtime_error { public: template<class Duration> nonexistent_local_time(const local_time<Duration>& tp, const local_info& i); }; }
类 std::chrono::ambiguous_local_time
namespace std::chrono { class ambiguous_local_time : public runtime_error { public: template<class Duration> ambiguous_local_time(const local_time<Duration>& tp, const local_info& i); }; }
类 std::chrono::sys_info
namespace std::chrono { struct sys_info { sys_seconds begin; sys_seconds end; seconds offset; minutes save; string abbrev; }; }
类 std::chrono::local_info
namespace std::chrono { struct local_info { static constexpr int unique = 0; static constexpr int nonexistent = 1; static constexpr int ambiguous = 2; int result; sys_info first; sys_info second; }; }
类 std::chrono::time_zone
namespace std::chrono { class time_zone { public: time_zone(time_zone&&) = default; time_zone& operator=(time_zone&&) = default; // 未指明的额外构造函数 string_view name() const noexcept; template<class Duration> sys_info get_info(const sys_time<Duration>& st) const; template<class Duration> local_info get_info(const local_time<Duration>& tp) const; template<class Duration> sys_time<common_type_t<Duration, seconds>> to_sys(const local_time<Duration>& tp) const; template<class Duration> sys_time<common_type_t<Duration, seconds>> to_sys(const local_time<Duration>& tp, choose z) const; template<class Duration> local_time<common_type_t<Duration, seconds>> to_local(const sys_time<Duration>& tp) const; }; }
类模板 std::chrono::zoned_traits
namespace std::chrono { template<class T> struct zoned_traits {}; template<> struct zoned_traits<const time_zone*> { static const time_zone* default_zone(); static const time_zone* locate_zone(string_view name); }; }
类模板 std::chrono::zoned_time
namespace std::chrono { template<class Duration, class TimeZonePtr = const time_zone*> class zoned_time { public: using duration = common_type_t<Duration, seconds>; private: TimeZonePtr zone_; // 仅用于阐释 sys_time<duration> tp_; // 仅用于阐释 using traits = zoned_traits<TimeZonePtr>; // 仅用于阐释 public: zoned_time(); zoned_time(const zoned_time&) = default; zoned_time& operator=(const zoned_time&) = default; zoned_time(const sys_time<Duration>& st); explicit zoned_time(TimeZonePtr z); explicit zoned_time(string_view name); template<class Duration2> zoned_time(const zoned_time<Duration2, TimeZonePtr>& zt); zoned_time(TimeZonePtr z, const sys_time<Duration>& st); zoned_time(string_view name, const sys_time<Duration>& st); zoned_time(TimeZonePtr z, const local_time<Duration>& tp); zoned_time(string_view name, const local_time<Duration>& tp); zoned_time(TimeZonePtr z, const local_time<Duration>& tp, choose c); zoned_time(string_view name, const local_time<Duration>& tp, choose c); template<class Duration2, class TimeZonePtr2> zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& zt); template<class Duration2, class TimeZonePtr2> zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& zt, choose); template<class Duration2, class TimeZonePtr2> zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& zt); template<class Duration2, class TimeZonePtr2> zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& zt, choose); zoned_time& operator=(const sys_time<Duration>& st); zoned_time& operator=(const local_time<Duration>& ut); operator sys_time<duration>() const; explicit operator local_time<duration>() const; TimeZonePtr get_time_zone() const; local_time<duration> get_local_time() const; sys_time<duration> get_sys_time() const; sys_info get_info() const; }; zoned_time() -> zoned_time<seconds>; template<class Duration> zoned_time(sys_time<Duration>) -> zoned_time<common_type_t<Duration, seconds>>; template<class TimeZonePtrOrName> using /*time-zone-representation*/ = // 仅用于阐释 conditional_t<is_convertible_v<TimeZonePtrOrName, string_view>, const time_zone*, remove_cvref_t<TimeZonePtrOrName>>; template<class TimeZonePtrOrName> zoned_time(TimeZonePtrOrName&&) -> zoned_time<seconds, /*time-zone-representation*/<TimeZonePtrOrName>>; template<class TimeZonePtrOrName, class Duration> zoned_time(TimeZonePtrOrName&&, sys_time<Duration>) -> zoned_time<common_type_t<Duration, seconds>, /*time-zone-representation*/<TimeZonePtrOrName>>; template<class TimeZonePtrOrName, class Duration> zoned_time(TimeZonePtrOrName&&, local_time<Duration>, choose = choose::earliest) -> zoned_time<common_type_t<Duration, seconds>, /*time-zone-representation*/<TimeZonePtrOrName>>; template<class Duration, class TimeZonePtrOrName, class TimeZonePtr2> zoned_time(TimeZonePtrOrName&&, zoned_time<Duration, TimeZonePtr2>, choose = choose::earliest) -> zoned_time<common_type_t<Duration, seconds>, /*time-zone-representation*/<TimeZonePtrOrName>>; }
类 std::chrono::leap_second
namespace std::chrono { class leap_second { public: leap_second(const leap_second&) = default; leap_second& operator=(const leap_second&) = default; // 未指明的额外构造函数 constexpr sys_seconds date() const noexcept; constexpr seconds value() const noexcept; }; }
类 std::chrono::time_zone_link
namespace std::chrono { class time_zone_link { public: time_zone_link(time_zone_link&&) = default; time_zone_link& operator=(time_zone_link&&) = default; // 未指明的额外构造函数 string_view name() const noexcept; string_view target() const noexcept; }; }
类模板 local-time-format-t
namespace std::chrono { template<class Duration> struct /*local-time-format-t*/ { // 仅用于阐释 local_time<Duration> time; // 仅用于阐释 const string* abbrev; // 仅用于阐释 const seconds* offset_sec; // 仅用于阐释 }; }