delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/02/16/14:32:21

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Message-ID: <38AAEDC1.B23C48C@swi.com>
Date: Wed, 16 Feb 2000 13:34:42 -0500
From: Paul Berrevoets <paul AT swi DOT com>
Organization: Halcyon Inc.
X-Mailer: Mozilla 4.7 [en] (WinNT; U)
X-Accept-Language: en
MIME-Version: 1.0
To: Songyu Lu <slu AT ncsa DOT uiuc DOT edu>
CC: cygwin AT sourceware DOT cygnus DOT com
Subject: Re: Timing Functions on Cygwin
References: <Pine DOT HPP DOT 3 DOT 95 DOT 1000216111736 DOT 27783A-200000 AT sangamon DOT ncsa DOT uiuc DOT edu>

This has been fixed in the snapshots since around June of last year.
--
Regards,
Paul

Songyu Lu wrote:

> 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!
>
> Raymond
> NCSA
>
>   ------------------------------------------------------------------------
> /* test timing:
>  *    get local time from time() and localtime(),
>  *    convert to time in seconds by mktime(),
>  *    supposed to get same values.
>  */
> #include <stdio.h>
> #include <time.h>
> #include <sys/time.h>
>
> main()
> {
>   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 */
>   tzset();
>   /*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,
>           (now-the_time));
>
>   return 0;
> }
>
>   ------------------------------------------------------------------------
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019