Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5398FB90.7000109@sbcglobal.net>
Date: Wed, 11 Jun 2014 21:00:00 -0400
From: bfdamkoehler <bfdamkoehler@...global.net>
To: musl@...ts.openwall.com
Subject: Re: REG_STARTEND (regex)


Hello,

I noticed an issue with localtime() in musl-1.1.2. In my environment TZ 
is set to EST5EDT. There is a test program below that demonstrates this. 
localtime() is returning with isdst == 1 for for a time_t value of 
1394327858 (08-Mar-14 20:17). Daylight savings time starts on 09-Mar-14. 
Note that if you decrement the time_t value in the test program isdst 
remains set.

This time_t value is the st_atime value of a file on my machine, as 
returned by stat64().

Just as further test I moved the file around to an AIX 5.2 machine, HPUX 
11.11, and OpenBSD 5.0 system and a Centos 6.5 linux machine. I used ls 
and tar on them to display the file date and they all came out as 
08-Mar-14 20:17, as does the output from my application if it is linked 
with the gcc libc. When my application is linked with musl it produces a 
time of 08-Mar-14 21:17.

I just wanted to mention that I had noticed this.

Bruce


#include                <stdio.h>
#include                <string.h>
#include                <stdlib.h>
#include                <time.h>

int main()
{
     time_t              bin_time = 1394327858;  /* should be 08-Mar-14 
20:17 but */
                                                 /* localtime returns 
isdst=1 so  */
                                                 /* it is 08-Mar-14 
21:17         */
     struct tm           *tm_ptr;
     char                *cptr;

//#define GO_BACK_N_DAYS_IN_TIME
#ifdef  GO_BACK_N_DAYS_IN_TIME
     bin_time = 1394327858 - ( (24 * 60 * 60) * 60);
#endif

     cptr = getenv("TZ");
     if( cptr == NULL )
         printf("the TZ environment variable is not defined\n");
     else
         printf("the TZ environment variable is set to %s\n", cptr);

     tm_ptr = localtime(&bin_time);
     printf("The local time is ...\n");
     printf("\t\ttm_sec ........... %d\n", tm_ptr->tm_sec);
     printf("\t\ttm_min ........... %d\n", tm_ptr->tm_min);
     printf("\t\ttm_hour .......... %d\n", tm_ptr->tm_hour);
     printf("\t\ttm_mday .......... %d\n", tm_ptr->tm_mday);
     printf("\t\ttm_mon ........... %d\n", tm_ptr->tm_mon);
     printf("\t\ttm_year .......... %d\n", tm_ptr->tm_year);
     printf("\t\ttm_wday .......... %d\n", tm_ptr->tm_wday);
     printf("\t\ttm_yday .......... %d\n", tm_ptr->tm_yday);
     printf("\t\ttm_is_dst......... %d\n", tm_ptr->tm_isdst);
     printf("\n\n");

     printf("tm_hour should be 20 and tm_is_dst should be 0 -- DST 
starts on 09-Mar-14.\n");
     printf("\n\n");

}


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.