Currently the time_select helper method defaults to year 1 as seen at
https://github.com/rails/rails/blob/master/actionview/lib/action_view/helpers/date_helper.rb#L832

This appears to be an issue when creating new Time values.

When assigning the multi-parameter values  (time(1i), time(2i), etc) for
the time, the code essentially creates a new time value with
Time.new(1,1,1,18,0,0) using 1 as the year.

This is the result I get on my servers running Ubuntu using year 1...

irb(main):001:0> time = Time.new(1,1,1,18,0,0)
=> 0001-01-01 18:00:00 +0000
irb(main):002:0> TZInfo::Timezone.get("America/Chicago").local_to_utc(time)
=> 0001-01-01 23:50:36 UTC

Note that the time when using the time zone is off by 5 hours and 50
minutes which appears to come from the LMT zone (local mean time) (no time
zones existed in year 1?)

But if I run the same code in my local dev enironment (a mac), I get the
following...

rb(main):001:0> time = Time.new(1,1,1,18,0,0)
=> 0001-01-01 18:00:00 -0500
irb(main):002:0> TZInfo::Timezone.get("America/Chicago").local_to_utc(time)
=> 0001-01-02 00:00:00 UTC

This results in the time using the correct time zone from my app.

If I use 2017 (current year) instead of 1, then both my local and Ubuntu
servers give me the same correct results.

So my question is, should the current year be used as the default instead
of 1 (which appears to be problematic)?

Andrew

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to