DST

Eric Norum norume at aps.anl.gov
Tue Mar 13 14:07:19 UTC 2007


On Mar 13, 2007, at 6:29 AM, Joel Sherrill wrote:

> Eric Norum wrote:
>> Does the newlib that's part of RTEMS-4.7 handle the TZ  
>> environment  variable properly?  I've got:
>>
>> TZ="CST6CDT,M3.2.0,M11.1.0"
>>
>> but RTEMS is still reporting CST time.
>>
>>
>> I built newlib from:
>> NEWLIB=newlib-1.14.0
>> NEWLIBDIFF=newlib-1.14.0-rtems4.7-20061019.diff
>>
>>
> What time function are you calling?
>
> Internally RTEMS does not know timezone.

Right, which is why I was asking about newlib.  Here's a little test  
code I stuck into an existing application:
{
struct tm *tm;
time_t now;
printf("TZ:\"%s\"\n", getenv("TZ"));
time(&now);
tm = localtime(&now);
printf ("%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d\n", 1900+tm->tm_year, tm- 
 >tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
tm = gmtime(&now);
printf ("%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d\n", 1900+tm->tm_year, tm- 
 >tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
}


And here's the output:
TZ:"CST6CDT,M3.2.0,M11.1.0"
2007-02-13 08:04:01
2007-02-13 14:04:01

The TZ variable looks right to me.
The GMT values are correct.  But the local time is 6 hours behind  
(CST) instead of 5 hours behind (CDT).

-- 
Eric Norum <norume at aps.anl.gov>
Advanced Photon Source
Argonne National Laboratory
(630) 252-4793





More information about the users mailing list