L
loudking
Hi there,
I was using 'mktime' funciton to convert some integers into time_t
struct. Here is my code:
sscanf(str, "%04u-%02u-%02u", &year, &month, &day);
expire.tm_year = year - 1900;
expire.tm_mon = month - 1;
expire.tm_mday = day;
expire.tm_hour = 0;
expire.tm_min = 0;
expire.tm_sec = 1;
expire.tm_isdst = -1;
if(mktime(&expire) == -1) {
ErrorFatal(0x0004, ERR_0004_EXPIRATION_DATE_NO_SENSE, str);
}
else {
strftime(buf, sizeof(buf), "%a %Y-%m-%d %H:%M:%S %Z",
&expire);
printf("Expire = %s\n", buf);
}
Now if the input is 1998-25-45, the output would be 2000-02-14.
But I would like the language to check for tme if the input time data
is correct or not, for example, 32 days in a month is appeartly wrong.
Is there such a function or library?
Thanks in advance!
I was using 'mktime' funciton to convert some integers into time_t
struct. Here is my code:
sscanf(str, "%04u-%02u-%02u", &year, &month, &day);
expire.tm_year = year - 1900;
expire.tm_mon = month - 1;
expire.tm_mday = day;
expire.tm_hour = 0;
expire.tm_min = 0;
expire.tm_sec = 1;
expire.tm_isdst = -1;
if(mktime(&expire) == -1) {
ErrorFatal(0x0004, ERR_0004_EXPIRATION_DATE_NO_SENSE, str);
}
else {
strftime(buf, sizeof(buf), "%a %Y-%m-%d %H:%M:%S %Z",
&expire);
printf("Expire = %s\n", buf);
}
Now if the input is 1998-25-45, the output would be 2000-02-14.
But I would like the language to check for tme if the input time data
is correct or not, for example, 32 days in a month is appeartly wrong.
Is there such a function or library?
Thanks in advance!