I have the following struct:
typedef struct Date {
short day, month, year;
} DATE;
I want to create a function that gets a time_t variable and convert it to DATE but I am having some issues with it.
Tried the following:
DATE timeTConverter(time_t date)
{
struct tm *giverTime;
giverTime = localtime(date);
DATE given;
given.day = giverTime->tm_mday;
given.month = giverTime->tm_mon++;
given.year = giverTime->tm_year;
return given;
}
But it doesn't seem to work. Any ideas?
localtime()takes a pointer totime_t, nottime_titself.Also incrementing
giverTime->tm_mondoesn't make sense because the result is not used. It seems you wanted to assigngiverTime->tm_mon + 1instead.