C ++ mktime改变了我tm_struct价值 [英] C++ mktime changes value of my tm_struct
本文介绍了C ++ mktime改变了我tm_struct价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从读取用户bMonth;
I read bMonth from user;
time_t timestamp = time(NULL);
tm* birthday = localtime(×tamp);
birthday->tm_mon = bMonth-1;
// now the tm_mon is set corectly
time_t birthStamp = mktime(birthday);
// now the tm_mon is 0
为什么mktime改变价值观?
Why mktime changes the values?
推荐答案
这个函数的调用自动调整的值
timeptr成员如果它们是偏离范围或-in tm_wday的情况下
和tm_yday-如果它们具有不匹配所描述的日期值
由其他成员。
A call to this function automatically adjusts the values of the members of timeptr if they are off-range or -in the case of tm_wday and tm_yday- if they have values that do not match the date described by the other members.
这篇关于C ++ mktime改变了我tm_struct价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文