0

I am using a form to get a user's time zone. The following code is used to display the set of time zones.

<%= form.time_zone_select :time_zone, ActiveSupport::TimeZone.all %>

It lists the set of all time zones without considering DST(Daylight Saving Time). Is there anyway by which I can get the list of time zones taking DST into consideration?

Ranjith Kumar
  • 201
  • 2
  • 6

1 Answers1

0

The time zones in that list do take DST into account. In other words, if the user selects one of those time zones, times will be daylight savings/summer time during the time of year that they should be daylight savings, and standard time the rest of the year.

[Edit] I'm curious as to why you would want to show whether a time zone has DST, but...

As far as I know, to figure out whether a time zone has DST, you need to do something like compare the local time offsets from UTC at midnight December 21 and midnight June 21. If they're different, there's DST.

Then you have to figure out whether the place you're talking about is in the northern or southern hemisphere. I'm not sure how you would do that, other than building the table yourself.

There's Javascript that does something like this. Look here: Getting the client's timezone in JavaScript and here: https://bitbucket.org/pellepim/jstimezonedetect.

Community
  • 1
  • 1
Lencho Reyes
  • 359
  • 3
  • 10
  • It works fine when I input the time zone. I am talking at the view level(in display of the dropdown), which does not take DST into consideration. – Ranjith Kumar Mar 12 '14 at 16:28
  • I'm having trouble imagining why you would need to pick DST in a time zone picker. Can you please explain more? – Lencho Reyes Apr 08 '15 at 23:43