-
Notifications
You must be signed in to change notification settings - Fork 52
Conversation
joakim-hove
commented
Sep 29, 2013
- All calls to util_make_date() -> ecl_util_make_date() in the libecl library.
- Check if time_t/mktime() can accept values before 1970 during configuration.
- If mktime() can not accept dates before 1970 : use hysterical heuristics to shift year into the interval [1970 - 2038).
… setting symbol TIME_T_1970 for environments which can not take dates before 1970.
…and shifts the years if neccessary.
{ | ||
time_t t = mktime( &ts ); | ||
if (t == -1) | ||
exit(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand. Isn't this slightly backwards? exit(0)
from main()
typically means "successful" while mktime()
returns -1
if an error occurred.
Also, is there a reason you're using POSIX interfaces when the standard <time.h>
also provides mktime()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arggh: How to interleave answers in this interface?
I don't understand. Isn't this slightly backwards? exit(0) from main() typically means "successful" while mktime() returns -1 if an error occurred.
yes - it is backwards; I was waiting for that comment. Will fix before merging.
The POSIX thing was an oversight though. Will fix.
Thanks for the review.
Just to follow up on the previous comment. The program below ought to print [something along the lines of]
(and return successfully) on all platforms that support a basic C runtime system. #include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void) {
int ret;
struct tm ts = { 0 };
ts.tm_mday = 1 ;
ts.tm_isdst = -1 ;
{
time_t t = mktime( &ts );
if (t == -1)
ret = EXIT_FAILURE;
else {
ret = EXIT_SUCCESS;
printf("Time = %s", ctime(&t));
}
}
return ret;
} |
http://stackoverflow.com/questions/471248/what-is-ultimately-a-time-t-typedef-to Joakim |
I stand corrected. Thanks a lot for bringing that to my attention. Apparently I never paid enough attention to the fine details of the specification. |
…ecking sizeof(time_t)