[Haskell-cafe] Working with multiple time zones

Daniel Fischer daniel.is.fischer at web.de
Sun Feb 17 11:26:23 EST 2008


Am Sonntag, 17. Februar 2008 16:09 schrieb Bjorn Bringert:
>
> Interesting, it works for me:
>
> $ ghc --make hsnow.hs -o hsnow
> [1 of 1] Compiling Main             ( hsnow.hs, hsnow.o )
> Linking hsnow ...
>
> $ ./hsnow Europe/Paris Europe/Moscow Europe/London
> Europe/Paris    2008-02-17 16:07:43.009057
> Europe/Moscow   2008-02-17 18:07:43.009057
> Europe/London   2008-02-17 15:07:43.009057
>
> $ ghc --version
> The Glorious Glasgow Haskell Compilation System, version 6.8.2
>
> $ uname -srv
> Darwin 8.11.1 Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28 PDT
> 2007; root:xnu-792.25.20~1/RELEASE_I386

Doesn't work for me:
dafis at linux:~> ghc --make hsnow.hs -o hsnw
[1 of 1] Compiling Main             ( hsnow.hs, hsnow.o )
Linking hsnw ...
dafis at linux:~> ./hsnw Europe/Moscow Europe/Paris Europe/London
Europe/Moscow   2008-02-17 18:37:24.107667
Europe/Paris    2008-02-17 18:37:24.107667
Europe/London   2008-02-17 18:37:24.107667
dafis at linux:~> ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.8.2

Adding some debug-code, we see that the TZ evironment variable is properly 
set, but the TimeZone returned by getTimeZone is always that of the first 
argument:

dafis at linux:~> ./hsnow Europe/Moscow Europe/Paris Europe/London
Just "Europe/Moscow"
2008-02-17 16:01:56.061005 UTC
MSK
Europe/Moscow   2008-02-17 19:01:56.061005
Just "Europe/Paris"
2008-02-17 16:01:56.061005 UTC
MSK
Europe/Paris    2008-02-17 19:01:56.061005
Just "Europe/London"
2008-02-17 16:01:56.061005 UTC
MSK
Europe/London   2008-02-17 19:01:56.061005


Looking at the code in HsTime.c, it might be a difference between localtime 
and localtime_r.





More information about the Haskell-Cafe mailing list