aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/values
diff options
context:
space:
mode:
authordenisovlev <denisovlev@ya.ru>2016-10-20 15:44:22 +0300
committerdenisovlev <denisovlev@ya.ru>2016-10-21 13:19:08 +0300
commit07ffe7a6211b2bac59f385f4a0a67d11e4d42c24 (patch)
treeda000295e5dd71d11eebfea28a35581bf828362e /activesupport/lib/active_support/values
parentf2c6db41ba56afb1529e4732c59622fc0cf9f3ba (diff)
downloadrails-07ffe7a6211b2bac59f385f4a0a67d11e4d42c24.tar.gz
rails-07ffe7a6211b2bac59f385f4a0a67d11e4d42c24.tar.bz2
rails-07ffe7a6211b2bac59f385f4a0a67d11e4d42c24.zip
Fix `ActiveSupport::TimeZone#strptime` cannot parse timestamps (%Q, %s)
Diffstat (limited to 'activesupport/lib/active_support/values')
-rw-r--r--activesupport/lib/active_support/values/time_zone.rb26
1 files changed, 15 insertions, 11 deletions
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb
index cb97a0e135..a562f33420 100644
--- a/activesupport/lib/active_support/values/time_zone.rb
+++ b/activesupport/lib/active_support/values/time_zone.rb
@@ -450,17 +450,21 @@ module ActiveSupport
raise ArgumentError, "invalid date" if parts.nil?
return if parts.empty?
- time = Time.new(
- parts.fetch(:year, now.year),
- parts.fetch(:mon, now.month),
- parts.fetch(:mday, parts[:year] || parts[:mon] ? 1 : now.day),
- parts.fetch(:hour, 0),
- parts.fetch(:min, 0),
- parts.fetch(:sec, 0) + parts.fetch(:sec_fraction, 0),
- parts.fetch(:offset, 0)
- )
-
- if parts[:offset]
+ if parts[:seconds]
+ time = Time.at(parts[:seconds])
+ else
+ time = Time.new(
+ parts.fetch(:year, now.year),
+ parts.fetch(:mon, now.month),
+ parts.fetch(:mday, parts[:year] || parts[:mon] ? 1 : now.day),
+ parts.fetch(:hour, 0),
+ parts.fetch(:min, 0),
+ parts.fetch(:sec, 0) + parts.fetch(:sec_fraction, 0),
+ parts.fetch(:offset, 0)
+ )
+ end
+
+ if parts[:offset] || parts[:seconds]
TimeWithZone.new(time.utc, self)
else
TimeWithZone.new(nil, self, time)