This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Date problem... : Bug report



Hi all,

This is in response to my own posting about date. I installed mingw32 and
compiled the same program below. And lo and behold, the times were reported
correctly.

I guess this means that there is a bug in the time functions. I don't think
I found this in you mailing list archives.

As always - thank you for your responses.
Narayan

>Hi,
>
>I am having problems with dates. I am writing a program to create
>importable files for a certain scheduler and for some reason some of the
>events appear 1 hour earlier than when set. The following hex numbers are
>in time_t format right from the datafile of the scheduler, they are to be
>read in reverse (HOB, LOB order of things):
>
>f0884334
>70da4434
>f02b4634
>707d4734
>
>They correspond to 8:00 AM entries for dates between october 14th - 17th
>(it does the same thing during April 1-4). The following code takes these
>hex numbers as command line input and outputs the date (took precaution to
>invert it just in case I input HOB-LOB in the wrong order).
>
>/************************/
>#include <stdio.h>
>#include <time.h>
>
>
>main(argc, argv)
>char **argv;
>int argc;
>{
>    time_t time_arg;
>    char *strptr;
>    char invert[BUFSIZ];
>    int i,j=0,k;
>    if ( argc < 2 ) exit(1);
>
>    for ( k=1; k < argc ; k++ )
>    {
>        time_arg = (time_t) strtoul( argv[k], &strptr, 16 );
>        printf("ctime %s %s\n",argv[k], ctime( &time_arg ));
>        for ( i = strlen( argv[k] )-1 ; i >= 0 ; i-= 2 )
>        {
>            invert[j] = argv[k][i-1];
>            invert[j+1] = argv[k][i];
>            j+=2;
>        }
>        invert[j] = '\0';
>        time_arg = (time_t) strtoul( invert, &strptr, 16 );
>
>        printf("ctime %s %s\n", invert, ctime( &time_arg ));
>        j=0;
>    }
>}
>
>/*******************/
> From the above code I get all these events to be at 7:00 AM instead of
>8:00 AM. 
>Could someone tell me if I am doing something wrong or if I should blame
>the scheduling software.

| Narayan     _/~~~~~~~~~~~~~~~~~~~~~ venkman1@ix.netcom.com ~~~~~~~~~~~~/
|Natarajan  _/                                   .       .____ _       _/
|         _/ "I am not a vegetarian        *   .     x  -(____/ |  _  /
|       _/ because I love animals;              ________/____/  \ ( )-----
|     _/ I am a vegetarian because I          ,/                _ ( -------
|   _/  hate plants."                        <________\       //  (_)-----
| _/                                       --<==  *    |_____/  _
|/  http://www.netcom.com/~venkman1                   -(_____) (_)-----
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]