Closed ccoupe closed 9 years ago
Hey @ccoupe,
I just noticed that if (on Windows) I disable the setting in the Date/Time settings to 'automatically adjust for daylight savings time' this issue appears to go away.
Here's the time with the setting disabled:
With it enabled:
Thanks for the update. That looks like a Ruby on Windows problem and not a Shoes bug for me to fix.
@ccoupe, I would tend to agree except I do NOT see that behavior running ruby w/o shoes...i.e if I just do a ruby -e "puts Time.now"
the time is ALWAYS correct. It's only when called like this:
cshoes.exe --ruby -e "puts Time.now"
does the issue show up.
A test of a little Shoes.app {para " #{Time.now" } would tell us whether the TZ problem exists in base Shoes or only when --ruby is used (my guess).
@kvberge , Confirmed. Shoes (the gui) has the same problem. I suspect it's missing the correct env var for time zones and defaulting to GMT.
This test app shows some interesting behaviour.
para "#{Time.now}\n"
para "#{Time.local(2015, 06, 19)}\n"
end
The second para - Time.local does get the time zone correct for both dst and not dst. Only Time.now seems to be confused by dst. Very mysterious.
If I compile Shoes on Windows with the RubyInstaller's ruby then Shoes does the correct thing for Time zones. If I compile Shoes with the mingw cross compiled ruby then the time zone problem appears. There does appears to be two different API's for gettimeoutday() in the win32 ruby source code which differ in how the timezone is dealt with. Too soon to say whether the problem is Mingw, Ruby or mine but I do know where to look.
For those who don't want to wait, I've uploaded http://walkabout.mvmanila.com/public/shoes/shoes-3.2.24-gtk2-32.exe that was built with the better Ruby.
Found it. When ./configure runs to build Ruby from source it generates ext/..../config.h file. There are two differences between the RubyInstaller's Ruby and the cross-compiled Ruby
$ diff ri-config.h x-config.h
202a203
> #define HAVE_BUILTIN___BUILTIN_BSWAP16 1
217a219
> #define LOCALTIME_OVERFLOW_PROBLEM 1
When I remove those two lines and cross compile Ruby and then use that to build Shoes and then install that in Windows, the proper time (and tz) is shown. Yay!
Do I know why Ruby 2.1.x mishandles TZ if that is defined? No. It seems like a ruby bug but they'll point fingers at the mingw cross compiler and I just don't care enough about Windows to start that food fight. I'm going to post-process the config.h after the ruby configure step. I'm a hack.
@ccoupe, Great work! This looks to have fixed the problem! Awesome job!
@kvberge Thanks for reporting success. I'll close the issue.
> cshoes.exe --ruby -e "puts Time.now
may not print the correct timezone and date/time.