diff options
author | Ken Mayer <ken@bitwrangler.com> | 2017-04-17 17:22:02 -0700 |
---|---|---|
committer | Chris Osborn and Ken Mayer <pair+chris+ken@pacerpro.com> | 2017-04-17 17:31:10 -0700 |
commit | 881def43e326c36a7870bcc3ba56dc4a006b9a38 (patch) | |
tree | a2dbba86c2d4f16f60fc7fc33c348ad82c5d1503 /activesupport/lib/active_support | |
parent | 32a1c30f3893286ba048c3b72d5d4bcc8f520311 (diff) | |
download | rails-881def43e326c36a7870bcc3ba56dc4a006b9a38.tar.gz rails-881def43e326c36a7870bcc3ba56dc4a006b9a38.tar.bz2 rails-881def43e326c36a7870bcc3ba56dc4a006b9a38.zip |
Add (more) documentation to to_time
There's a difference in the results between `Date#to_time(:local)` and
`Date#in_time_zone` but it is subtle and can confuse users (like me :-).
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/core_ext/date/conversions.rb | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/date/conversions.rb b/activesupport/lib/active_support/core_ext/date/conversions.rb index d553406dff..c6c30aa835 100644 --- a/activesupport/lib/active_support/core_ext/date/conversions.rb +++ b/activesupport/lib/active_support/core_ext/date/conversions.rb @@ -79,6 +79,9 @@ class Date # date.to_time(:local) # => 2007-11-10 00:00:00 0800 # # date.to_time(:utc) # => 2007-11-10 00:00:00 UTC + # + # NOTE: The :local timezone is Ruby's *process* timezone, i.e. ENV['TZ'] + # If the *application's* timezone is needed, then use +in_time_zone+ instead def to_time(form = :local) raise ArgumentError, "Expected :local or :utc, got #{form.inspect}." unless [:local, :utc].include?(form) ::Time.send(form, year, month, day) |