summaryrefslogtreecommitdiff
path: root/lib/time.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-05 14:03:34 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-05 14:03:34 +0000
commit5fa7cdbde54bed9bda3f9de20d621989a19ddc3b (patch)
treefdb4f26212caebd3f88b3869e2e5b4ca9106e51f /lib/time.rb
parent2d8841791facb07155c710d8a7db7b0bf8be0d21 (diff)
Time.parse's "now" argument as nil works again.
* lib/time.rb (make_time): "now" argument as nil works again. This is broken since Ruby 2.2. Mathieu Jobin pointed a problem. https://github.com/ruby/ruby/commit/e4b05d91eb0d48fd172abf015c493bb42d755d07#commitcomment-17421387 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/time.rb')
-rw-r--r--lib/time.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/time.rb b/lib/time.rb
index 69e524fd61..5179e9fee4 100644
--- a/lib/time.rb
+++ b/lib/time.rb
@@ -254,14 +254,18 @@ class Time
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 year || now
+ off_year = year || now.year
+ off = zone_offset(zone, off_year) if zone
+ end
- if off
- now = now.getlocal(off) if now.utc_offset != off
- else
- now = now.getlocal
+ if now
+ if off
+ now = now.getlocal(off) if now.utc_offset != off
+ else
+ now = now.getlocal
+ end
end
usec = nil