1
good afternoon.
I’m having a hard time with the C-date manipulation. I’m using the time. h library to mess with dates.
I need to create a struct tm
which contains the date of the day (example) 29/01/1950 and then save its value time_t
in a variable.
The problem is that I create the structure, assign the values of the day/month/year to their respective variables (tm_mday
, tm_mon
and tm_year
), but when I use the function mktime()
, he returns me -1.
Excerpt from the code:
data->tm_mday = dia;
data->tm_mon = mes - 1;
data->tm_year = ano - 1900;
segs = mktime(data);
I was not having problems with this solution for recent dates.
What might be going on?
EDIT 1: Running a loop to see how far mktime() works, I realized that it works until the value of tm_year equals 70. Below this it returns me -1...
EDIT 2: Doing a few more tests, I noticed that the value that mktime() returns is the number of seconds since 31/12/1969 22:00. Any date before that I can’t create with that structure.