From 06a7c2948a8dbf31357b552d468fcf42002736e7 Mon Sep 17 00:00:00 2001 From: gbuesing Date: Thu, 8 May 2008 21:30:17 -0500 Subject: Time.zone.parse: return nil for strings with no date information --- activesupport/lib/active_support/values/time_zone.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/values') diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index d597d99880..0fa99135e2 100644 --- a/activesupport/lib/active_support/values/time_zone.rb +++ b/activesupport/lib/active_support/values/time_zone.rb @@ -213,8 +213,10 @@ class TimeZone # Time.zone.now # => Fri, 31 Dec 1999 14:00:00 HST -10:00 # Time.zone.parse('22:30:00') # => Fri, 31 Dec 1999 22:30:00 HST -10:00 def parse(str, now=now) + date_parts = Date._parse(str) + return if date_parts.blank? time = Time.parse(str, now) rescue DateTime.parse(str) - if Date._parse(str)[:offset].nil? + if date_parts[:offset].nil? ActiveSupport::TimeWithZone.new(nil, self, time) else time.in_time_zone(self) -- cgit v1.2.3