This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
Beta 17.1 mktime() weirdness?
- To: gnu-win32 at cygnus dot com
- Subject: Beta 17.1 mktime() weirdness?
- From: Shankar Ramamoorthy <shankar at viman dot com>
- Date: Tue, 08 Jul 1997 17:57:27 -0700
Does anybody know of any weirdness with mktime in Beta 17.1?
I find that
x != mktime(localtime(&x))
which is true on my SPARC Solaris 2.x box.
Contrarywise,
x == mktime(gmtime(&x))
under Cygwin B 17.1 which not true under Solaris.
An example x is 812556000.
The problem seems to be that mktime(struct tm *tm) thinks that the
*tm is a GMT time, whereas it should be treated as a local time. It
doesn't matter what I set tm_isdst in the struct tm to, it always
returns the same value.
Here's a simple C++ program to illustrate the problem:
#include <iostream.h>
#include <sys/time.h>
#include <time.h>
int main ()
{
struct tm tmTimeGMT, tmTimeLocal, *tmTimeP;
time_t tTimeRef, tTimeGMT, tTimeLocal;
tTimeRef = 812556000;
tmTimeP = localtime(&tTimeRef);
memcpy((void *) &tmTimeLocal, (void *) tmTimeP, sizeof(tmTimeLocal));
tmTimeP = gmtime(&tTimeRef);
memcpy((void *) &tmTimeGMT, (void *) tmTimeP, sizeof(tmTimeGMT));
tTimeLocal = mktime(&tmTimeLocal);
tTimeGMT = mktime(&tmTimeGMT);
cout << "Reference time was <" << tTimeRef << ">\n";
cout << "Local time was <" << tTimeLocal << ">\n";
cout << "GMT time was <" << tTimeGMT << ">\n";
exit(0);
} // main()
On Solaris I get:
Reference time was <812556000>
Local time was <812556000>
GMT time was <812584800>
Under Cygwin Beta 17 (under NT 4.0) I get:
Reference time was <812556000>
Local time was <812530800>
GMT time was <812556000>
Maybe its fixed in Beta 18? But I cant really switch right now.
Any work around?
Shankar
shankar@viman.com
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".