[uClibc]Can not get localtime for BRECIS MIPS board

Erik Andersen andersen at codepoet.org
Thu Aug 1 20:48:17 UTC 2002


On Thu Aug 01, 2002 at 10:11:56AM +0700, VAN DUC UY wrote:
> Hello all,
> I can not get the localtime for my system (kernel 2.4.14, uClibc-0.9.12,
> mips-gcc 3.1, BRECIS MPS3000). the localtime() function on uClibc-0.9.12
> always return me a GMT time.
> 
> Can anybody show me the way to get localtime for my application ?

You need to be sure the TZ environment variable is set properly,
since uClibc does not support /etc/zoneinfo junk.
See 'man 3 tzset' or read the SuSv3 docs at
http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap08.html   
for details on how to set TZ for localtime.

For example, here is date with glibc:
    $ date
    Thu Aug  1 14:31:58 MDT 2002

Here is date with uClibc, when the TZ environment variable is set:

    $ TZ=MDT6 ./busybox date
    Thu Aug  1 14:34:53 MDT 2002

This means that MST (Mountain Daylight Time) is 6 hours earlier
than Coordinated Universal Time (UTC) and does not have daylight
saving time.

Here is another simple example:

    $ TZ=JST-9 ./busybox date
    Fri Aug  2 05:40:45 JST 2002

This means that Japanese Standard Time (JST) is 9 hours earlier
than Coordinated Universal Time (UTC) and does not have daylight
saving time.


Here is a more complex example:

    $ TZ=MST7MDT ./busybox date
    Thu Aug  1 14:32:04 MDT 2002

This means that Mountain Standard Time (MST) is 7 hours earlier
than Coordinated Universal Time (UTC).  Both standard time and
daylight saving time apply to this locale.  By default Mountain
Daylight Time (MDT) is one hour ahead of MST.  Since it isn't
otherwise specified, daylight saving time starts on the first
Sunday of April at 2:00 A.M. and ends on the last Sunday of
October at 2:00 A.M.

Here is an even uglier example:

    $ TZ=NST3:30NDT1:30 ./busybox date
    Thu Aug  1 19:13:03 NDT 2002

This means that Newfoundland Standard Time (NST) is 3.5 hours
earlier than Coordinated Universal Time (UTC).  Both standard
time and daylight saving time apply to this locale.  Newfoundland
Daylight Time is 1.5 hours earlier than Coordinated Universal
Time (UTC).
 
Normally, one would set TZ in /etc/profile.

 -Erik

--
Erik B. Andersen             http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--



More information about the uClibc mailing list