Shoes may not respect timezones #123

Closed
ccoupe opened this Issue May 2, 2015 · 12 comments

Comments

Projects
None yet
2 participants
@ccoupe
Contributor

ccoupe commented May 2, 2015

> cshoes.exe --ruby -e "puts Time.now
may not print the correct timezone and date/time.

@kvberge

This comment has been minimized.

Show comment
Hide comment
@kvberge

kvberge Jun 19, 2015

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:
time_ok

With it enabled:
time_not_ok

kvberge commented Jun 19, 2015

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:
time_ok

With it enabled:
time_not_ok

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Jun 19, 2015

Contributor

Thanks for the update. That looks like a Ruby on Windows problem and not a Shoes bug for me to fix.

Contributor

ccoupe commented Jun 19, 2015

Thanks for the update. That looks like a Ruby on Windows problem and not a Shoes bug for me to fix.

@ccoupe ccoupe closed this Jun 19, 2015

@kvberge

This comment has been minimized.

Show comment
Hide comment
@kvberge

kvberge Jun 19, 2015

@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.

kvberge commented Jun 19, 2015

@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.

@ccoupe ccoupe reopened this Jun 19, 2015

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Jun 19, 2015

Contributor

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).

Contributor

ccoupe commented Jun 19, 2015

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).

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Jun 19, 2015

Contributor

@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.

Contributor

ccoupe commented Jun 19, 2015

@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.

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Jun 20, 2015

Contributor

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.

Contributor

ccoupe commented Jun 20, 2015

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.

ccoupe added a commit that referenced this issue Jun 20, 2015

@ccoupe ccoupe self-assigned this Jun 22, 2015

@ccoupe ccoupe added this to the 3.2.24 milestone Jun 22, 2015

@ccoupe ccoupe added the High label Jun 22, 2015

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Jun 22, 2015

Contributor

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.

Contributor

ccoupe commented Jun 22, 2015

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.

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Jun 22, 2015

Contributor

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.

Contributor

ccoupe commented Jun 22, 2015

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.

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Jun 24, 2015

Contributor

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.

Contributor

ccoupe commented Jun 24, 2015

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.

@kvberge

This comment has been minimized.

Show comment
Hide comment
@kvberge

kvberge Jun 25, 2015

@ccoupe, Great work! This looks to have fixed the problem! Awesome job!

kvberge commented Jun 25, 2015

@ccoupe, Great work! This looks to have fixed the problem! Awesome job!

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Jun 25, 2015

Contributor

@kvberge Thanks for reporting success. I'll close the issue.

Contributor

ccoupe commented Jun 25, 2015

@kvberge Thanks for reporting success. I'll close the issue.

@ccoupe ccoupe closed this Jun 25, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment