获取固定大小整数的时间
Get time as fixed size integer
当你有时间的时候通过此结构:http://www.cplusplus.com/reference/ctime/tm/可以看到这些值(例如,tm_sec, tm_min
)都是int
的。问题是我想将这些int
存储在某个地方。但是我想使用int32_t
类型而不是int
,以便大小是固定的。对此我能做些什么吗?
C++从 C 获取struct tm
类型。根据C标准,这些struct tm
元素具有一定的范围:
C99 §7.23.1 时间的组成部分
tm
结构应至少包含以下成员,顺序不限。成员的语义及其正常范围在注释中表示。int tm_sec; //seconds after the minute — [0, 60] int tm_min; //minutes after the hour — [0, 59] int tm_hour; //hours since midnight — [0, 23] int tm_mday; //day of the month — [1, 31] int tm_mon; //months since January — [0, 11] int tm_year; //years since 1900 int tm_wday; //days since Sunday — [0, 6] int tm_yday; //days since January 1 — [0, 365] int tm_isdst; // Daylight Saving Time flag
这些值可以安全地转换为int32_t
。
相关文章:
- 有序地图字符串搜索与整数搜索之间的时间复杂度
- 使用不同的整数组装字符数组以类似于日期和时间
- 计算以毫秒为单位的分类算法对整数阵列排序的时间
- 编译时间递归函数以计算两个整数的下一个功能
- 保存未知数量的整数,而不会花费太多时间/内存
- 使用时间作为函数中计算的整数
- 将带有时间戳的向量整数连接为C++中的字符串
- 将日期和时间字符串转换为 C++ 中的整数
- 将标准::时间与随机整数混合
- 获取固定大小整数的时间
- 将高分辨率时钟时间转换为整数(Chrono)
- 寻找在时间上为O(n),在空间上为O(1)的重复有符号整数
- 在有效时间内将一个正整数写成2的幂的和的方法总数
- 从32位整数中获取GPS时间
- C++:使用 STL 排序对不同列上的整数 2d 数组进行排序的时间复杂度
- 通过C++模板编译从整数到类型的时间查找
- C/C++:如何获取构建时间的整数unix时间戳(而不是字符串)
- 如何处理无法在整数中存储时间
- 如何从中获取持续时间,如整数毫秒和浮点秒<chrono>数?
- 将整数转换为时间格式