summaryrefslogtreecommitdiff
path: root/lib/time.rb
diff options
context:
space:
mode:
authorsonots <sonots@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-17 17:46:22 +0000
committersonots <sonots@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-17 17:46:22 +0000
commit1ba62fa93a200f92a8bd612a14f36a298ac4b3d1 ()
tree08482a678d9ee82ca5296764028d450bf36e90b3 /lib/time.rb
parent2169bea82e57c3887285b06f36b0f79827de0986 (diff)
* lib/time.rb (parse, strptime): Fix Time.parse/strptime does not
have compatibility with DateTime.parse/strptime in terms of parsing timezone [Bug #12190] [Fix GH-1297] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--lib/time.rb20
1 files changed, 13 insertions, 7 deletions
@@ -249,14 +249,18 @@ class Time
end
private :apply_offset
- def make_time(date, year, mon, day, hour, min, sec, sec_fraction, zone, now)
if !year && !mon && !day && !hour && !min && !sec && !sec_fraction
raise ArgumentError, "no time information in #{date.inspect}"
end
- off_year = year || now.year
off = nil
- off = zone_offset(zone, off_year) if zone
if off
now = now.getlocal(off) if now.utc_offset != off
@@ -287,8 +291,10 @@ class Time
sec ||= 0
usec ||= 0
- if year != off_year
- off = nil
off = zone_offset(zone, year) if zone
end
@@ -363,7 +369,7 @@ class Time
d = Date._parse(date, comp)
year = d[:year]
year = yield(year) if year && !comp
- make_time(date, year, d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now)
end
#
@@ -441,7 +447,7 @@ class Time
else
year = d[:year]
year = yield(year) if year && block_given?
- t = make_time(date, year, d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now)
end
t
end