Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daylight saving not being considered #35

Closed
brauliobo opened this issue Jan 13, 2015 · 2 comments
Closed

Daylight saving not being considered #35

brauliobo opened this issue Jan 13, 2015 · 2 comments
Labels

Comments

@brauliobo
Copy link

@brauliobo brauliobo commented Jan 13, 2015

On the system (ubuntu 14.10) I get:

~/P/n/blogoosfero git:blogoosfero ❯❯❯ TZ='America/Bahia' date                                                                                                                          
Ter Jan 13 13:38:27 BRT 2015
~/P/n/blogoosfero git:blogoosfero ❯❯❯ TZ='America/Sao_Paulo' date                                                                                                                       
Ter Jan 13 14:38:32 BRST 2015

And on Rails console I get:

irb(main):002:0> Time.zone = 'America/Bahia'
=> "America/Bahia"
irb(main):003:0> Time.zone.formatted_offset
=> "-03:00"
irb(main):004:0> Time.zone = 'America/Sao_Paulo'
=> "America/Sao_Paulo"
irb(main):005:0> Time.zone.formatted_offset
=> "-03:00"

I'm using rails 3.2.21 and tzinfo 0.3.42 (as required by activerecord 3.2.21)

@philr
Copy link
Member

@philr philr commented Jan 13, 2015

According to the Rails source code, the ActiveSupport::TimeZone#formatted_offset method returns the difference between UTC and the standard time for the zone. It will not take daylight savings time into account.

If you want to find the current offset, you can use the ActiveSupport::TimeWithZone#formatted_offset method instead:

  > Time.zone = 'America/Bahia'
 => "America/Bahia" 
  > Time.zone.now.formatted_offset
 => "-03:00" 
  > Time.zone = 'America/Sao_Paulo'
 => "America/Sao_Paulo" 
  > Time.zone.now.formatted_offset
 => "-02:00" 
@philr philr added the invalid label Jan 13, 2015
@philr philr closed this Jan 13, 2015
@brauliobo
Copy link
Author

@brauliobo brauliobo commented Jan 13, 2015

thanks @philr !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.