This is the mail archive of the
mailing list for the Cygwin project.
Timing Functions on Cygwin
- To: cygwin at sourceware dot cygnus dot com
- Subject: Timing Functions on Cygwin
- From: Songyu Lu <slu at ncsa dot uiuc dot edu>
- Date: Wed, 16 Feb 2000 11:22:04 -0600 (CST)
- cc: slu at ncsa dot uiuc dot edu
I have trouble with timing functions(time(), localtime(),
tzset(), mktime()) on Cygwin using gcc compiler.
I wrote a simple program attached.
It basicly converts the value from time()(call it A) to tm structure, then
converts this tm back to a value in seconds using tzset() and
mktime()(call it B). A and B are supposed to be equal. Cygwin gives me a
6 hours difference(I am in Central Time Zone), while other systems(I tried
IRIX, Linux, Sun OS) work well.
Hope you can give me a hint!
/* test timing:
* get local time from time() and localtime(),
* convert to time in seconds by mktime(),
* supposed to get same values.
struct tm *tm;
time_t now, the_time;
/*get current time in seconds.*/
now = time(0);
/* convert to tm structure */
tm = localtime(&now);
/*adjust to local time zone and daylight saving time */
/*convert tm structure to time in seconds. Cygwin returns Greenwich time
here while other systems return local time. */
the_time = mktime(tm);
fprintf(stderr, "tm->tm_isdst=%d\n", tm->tm_isdst);
fprintf(stderr, "now=%d,\nthe_time=%d,\nnow - the_time=%d\n", now, the_time,
Want to unsubscribe from this list?
Send a message to firstname.lastname@example.org