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

Timezone offsets in time_zone_select not taking into consideration DST #21942

Closed
MatTarantini opened this issue Oct 12, 2015 · 8 comments
Closed

Comments

@MatTarantini
Copy link

@current_period.utc_offset if @current_period

I would recommend changing this to utc_total_offset to take Daylight Savings Time into consideration, unless this was done on purpose for a reason that I'm currently unaware of.

Example: time_zone_select shows US/Pacific as "(GMT-08:00) US/Pacific", when it should be -07:00 right now.

@pixeltrix
Copy link
Contributor

This is a presentational issue - the question is whether we should show the current offset in the popup menu or not. It's arguable that either is correct or even that we shouldn't show the offset at all. I think this would be best solved by moving the presentational aspect of the content to locales as we've looked at before.

@MatTarantini
Copy link
Author

@pixeltrix Thanks for the response.

I've had quite a few clients contact me worried that the incorrect offset on the timezone select would transfer over to issues on the website.

Personally, I would keep the offset display on each timezone since people use them as a quick guide to find the general area where they will then start reading the timezone names.

And I agree that it would be nice to have more control over the presentation of the timezones listed through locales.

Any idea which way this might be going?
Also, is there anything that I can do at the moment to display the current offset and put my clients at ease?

@kv109
Copy link
Contributor

kv109 commented Nov 6, 2015

@MatTarantini, maybe you should check out ActiveSupport::TimeWithZone? Its #formatted_offset takes DST into consideration:

assert_equal '-05:00', ActiveSupport::TimeWithZone.new(Time.utc(2000, 1), @time_zone).formatted_offset
assert_equal '-04:00', ActiveSupport::TimeWithZone.new(Time.utc(2000, 6), @time_zone).formatted_offset #dst

See this test.

@pixeltrix
Copy link
Contributor

@MatTarantini it's relatively easy to construct your own timezone select helper method - I'm looking at moving it out to locales for Rails 5.

@kv109
Copy link
Contributor

kv109 commented Nov 7, 2015

@pixeltrix
What do you think about adding following option:

TimeZone.to_s(utc_total_offset: true) #=> "(GMT+02:00) Amsterdam"
TimeZone.to_s                         #=> "(GMT+01:00) Amsterdam"

?
https://github.com/rails/rails/compare/master...kv109:21501?expand=1

UPDATE: test added.

@rails-bot
Copy link

This issue has been automatically marked as stale because it has not been commented on for at least
three months.

The resources of the Rails team are limited, and so we are asking for your help.

If you can still reproduce this error on the 5-0-stable branch or on master,
please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions.

@avit
Copy link
Contributor

avit commented Oct 10, 2016

I'm guessing that any use of time_zone_select might be used alongside a date_select or date_field or similar.

This is going to be impossible to resolve on server-side so it shows the correct offset based on changing inputs. I would recommend closing this issue.

Any listing of time zones is always given as the Standard offset, without DST:

https://en.wikipedia.org/wiki/List_of_UTC_time_offsets

@pixeltrix
Copy link
Contributor

Agree with @avit - closing

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

No branches or pull requests

6 participants