首页 > 代码库 > c++ time_t
c++ time_t
type
struct tm
<ctime>
Time structure
Structure containing a calendar date and time broken down into its components.The structure contains nine members of type int, which are (in any order):
| int tm_sec;int tm_min;int tm_hour;int tm_mday;int tm_mon;int tm_year;int tm_wday;int tm_yday;int tm_isdst; |
而直接存储年月日的是一个结构:
struct tm
{
int tm_sec; /*秒,正常范围0-59, 但允许至61*/
int tm_min; /*分钟,0-59*/
int tm_hour; /*小时, 0-23*/
int tm_mday; /*日,即一个月中的第几天,1-31*/
int tm_mon; /*月, 从一月算起,0-11*/ 1+p->tm_mon;
int tm_year; /*年, 从1900至今已经多少年*/ 1900+ p->tm_year;
int tm_wday; /*星期,一周中的第几天, 从星期日算起,0-6*/
int tm_yday; /*从今年1月1日到目前的天数,范围0-365*/
int tm_isdst; /*日光节约时间的旗标*/
};
The meaning of each is:
The Daylight Saving Time flag (tm_isdst) is greater than zero if Daylight Saving Time is in effect, zero if Daylight Saving Time is not in effect, and less than zero if the information is not available.
* tm_sec is generally 0-59. Extra range to accommodate for leap seconds in certain systems.
struct tm
{
int tm_sec; /*秒,正常范围0-59, 但允许至61*/
int tm_min; /*分钟,0-59*/
int tm_hour; /*小时, 0-23*/
int tm_mday; /*日,即一个月中的第几天,1-31*/
int tm_mon; /*月, 从一月算起,0-11*/ 1+p->tm_mon;
int tm_year; /*年, 从1900至今已经多少年*/ 1900+ p->tm_year;
int tm_wday; /*星期,一周中的第几天, 从星期日算起,0-6*/
int tm_yday; /*从今年1月1日到目前的天数,范围0-365*/
int tm_isdst; /*日光节约时间的旗标*/
};
需要特别注意的是,年份是从1900年起至今多少年,而不是直接存储如2011年,月份从0开始的,0表示一月,星期也是从0开始的, 0表示星期日,1表示星期一。
The meaning of each is:
Member | Meaning | Range |
---|---|---|
tm_sec | seconds after the minute | 0-61* |
tm_min | minutes after the hour | 0-59 |
tm_hour | hours since midnight | 0-23 |
tm_mday | day of the month | 1-31 |
tm_mon | months since January | 0-11: real month = tm_mon + 1 |
tm_year | years since 1900 | 1900+tm_year |
tm_wday | days since Sunday | 0-6 |
tm_yday | days since January 1 | 0-365 |
tm_isdst | Daylight Saving Time flag |
* tm_sec is generally 0-59. Extra range to accommodate for leap seconds in certain systems.
c++ time_t
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。