[erlang-questions] erlang:localtime_to_universaltime/2 work unexpect?

Raimo Niskanen raimo+erlang-questions@REDACTED
Fri May 9 09:08:37 CEST 2008


On Fri, May 09, 2008 at 12:21:57PM +0800, ?????? wrote:
> Hi everyone.
> When I using erlang:localtime_to_universaltime/2 , I have some doubt.
> My time zone is GMT + 8, asia/shanghai(china).
> this segment is printed out from my erl:
> 
> > lists:map(fun(I) -> erlang:localtime_to_universaltime(I, true) end, [
> {{1977, 7, 10}, {10, 20, 03}},
> {{1978, 7, 10}, {10, 20, 03}},
> {{1997, 7, 10}, {10, 20, 03}},
> {{1999, 7, 10}, {10, 20, 3}},
> {{2000, 7, 10}, {10, 20, 3}},
> {{2008, 5, 9}, {10, 20, 03}}]).
> 
> [{{1977,7,10},{2,20,3}},
>  {{1978,7,10},{1,20,3}},
>  {{1997,7,10},{1,20,3}},
>  {{1999,7,10},{1,20,3}},
>  {{2000,7,10},{2,20,3}},
>  {{2008,5,9},{2,20,3}}]
> 
> 
> 
> I find from 1978 to 1999 the DST is active, other not.
> I can't understand why have this  phenomenon. everyone can give me an
> answer?
> thanks!
> 

You should have a look at the timezone definitions in your host OS.
On e.g linux use:
	zdump -v /etc/localtime
That will give you the definition your host OS uses.

For me in Europe/Stockholm using your example I get DST from 1997
but not earlier.  In the zdump output it is clear that
DST was defined 1916 but then not until 1980 and if
I recall correctly that is the truth from political decisions.

> 
> 
> -- 
> ??????
> ---------------------------------------------------------
> ????????????
> ????????????

> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list