Unfortunately you can't set an explicit year to be used with a time_select
(when the time is nil).

The issue is that TZ math IS occurring already implicitly in Rails core
when creating a new time object without a timezone.  When the year defaults
to 1 my times are being offset by 5 hours and 50 minutes automatically
because it's using LMT as a zone which I assume is because year 1 has no
time zones.  As mentioend in my original message, this is not an issue on
my mac (it uses the apps correct default timezone), but on Ubuntu it's
using LMT as a zone in year 1.

When the time value is nil, there needs to be a way to set the default
year.  Perhaps a PR is required for setting an explicit default if "1" is
considered an acceptable default currently?


On Tue, Jul 25, 2017 at 1:46 AM, Matthew Draper <matt...@trebex.net> wrote:

>
> > Any comments on why year 1 is used as the default?  This appears to have
> been made as the choice 9 or so years ago.  It's an easy change, but it'd
> be nice to hear a reason why 1 has been used as the default before I open a
> new PR.
>
>
> It looks like it was https://github.com/rails/rails/pull/4641
>
>
> From context, I surmise that only date_select was particularly considered,
> which would explain why it didn’t really matter what the default was,
> beyond the fact it existed.
>
>
>
> My possible concerns around changing this are:
>
> * existing callers, especially of a (more common?) year-ignoring
> date_select, may be relying on the current value
>
> * making the default a value that changes over time seems to risk future
> surprises
>
>
> Tying in with the latter, I’d generally advise against doing TZ math on a
> datetime whose year you don’t know / is undefined. If your use case means
> you know it’s definitely the current year, you probably want to be explicit
> about that, and not rely on a default anyway.
>
>
> --
> 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.
>

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