From: Tanaka Akira Date: 2010-08-26T23:44:26+09:00 Subject: Re: Time.local and offsets 2010/8/26 Xavier Noria : > Does anyone know why Time.local gives these offsets here? (+0100 is correct) % TZ=Europe/Madrid ruby -ve 'p Time.local(2010); p Time.local(1940); p Time.local(1807)' ruby 1.8.7 (2010-06-23 patchlevel 299) [x86_64-linux] Fri Jan 01 00:00:00 +0100 2010 Mon Jan 01 00:00:00 +0000 1940 Thu Jan 01 00:00:00 -0014 1807 % TZ=Europe/Madrid ./ruby -ve 'p Time.local(2010); p Time.local(1940); p Time.local(1807)' ruby 1.9.3dev (2010-08-26 trunk 29102) [x86_64-linux] 2010-01-01 00:00:00 +0100 1940-01-01 00:00:00 +0000 1807-01-01 00:00:00 -0014 % TZ=Europe/Madrid ./ruby -ve 'p Time.local(2010); p Time.local(1940); p Time.local(1807)' ruby 1.9.2p0 (2010-08-18 revision 29034) [x86_64-linux] 2010-01-01 00:00:00 +0100 1940-01-01 00:00:00 +0000 1807-01-01 00:00:00 -0015 % zdump -v Europe/Madrid|head Europe/Madrid -9223372036854775808 = NULL Europe/Madrid -9223372036854689408 = NULL Europe/Madrid Tue Jan 1 00:14:43 1901 UTC = Mon Dec 31 23:59:59 1900 LMT isdst=0 gmtoff=-884 Europe/Madrid Tue Jan 1 00:14:44 1901 UTC = Tue Jan 1 00:14:44 1901 WET isdst=0 gmtoff=0 Europe/Madrid Sat May 5 22:59:59 1917 UTC = Sat May 5 22:59:59 1917 WET isdst=0 gmtoff=0 Europe/Madrid Sat May 5 23:00:00 1917 UTC = Sun May 6 00:00:00 1917 WEST isdst=1 gmtoff=3600 Europe/Madrid Sat Oct 6 22:59:59 1917 UTC = Sat Oct 6 23:59:59 1917 WEST isdst=1 gmtoff=3600 Europe/Madrid Sat Oct 6 23:00:00 1917 UTC = Sat Oct 6 23:00:00 1917 WET isdst=0 gmtoff=0 Europe/Madrid Mon Apr 15 22:59:59 1918 UTC = Mon Apr 15 22:59:59 1918 WET isdst=0 gmtoff=0 Europe/Madrid Mon Apr 15 23:00:00 1918 UTC = Tue Apr 16 00:00:00 1918 WEST isdst=1 gmtoff=3600 % zdump -v Europe/Madrid|grep 2010 Europe/Madrid Sun Mar 28 00:59:59 2010 UTC = Sun Mar 28 01:59:59 2010 CET isdst=0 gmtoff=3600 Europe/Madrid Sun Mar 28 01:00:00 2010 UTC = Sun Mar 28 03:00:00 2010 CEST isdst=1 gmtoff=7200 Europe/Madrid Sun Oct 31 00:59:59 2010 UTC = Sun Oct 31 02:59:59 2010 CEST isdst=1 gmtoff=7200 Europe/Madrid Sun Oct 31 01:00:00 2010 UTC = Sun Oct 31 02:00:00 2010 CET isdst=0 gmtoff=3600 It seems Madrid used different timezone rules in these days: LMT (local mean time) and WET/WEST. > Thu Jan 01 00:00:00 -0014 1807 14 is (884/60.0).floor. > 1807-01-01 00:00:00 -0015 15 is (884/60.0).round. -- Tanaka Akira