ruby-changes:61334
From: Henrik <ko1@a...>
Date: Sat, 23 May 2020 09:43:23 +0900 (JST)
Subject: [ruby-changes:61334] fdb31aa7ab (master): Time.xmlschema: Clarify error and docs
https://git.ruby-lang.org/ruby.git/commit/?id=fdb31aa7ab From fdb31aa7ab1bb1718e57e2e052caff959af3111e Mon Sep 17 00:00:00 2001 From: Henrik Nyh and Tomas Skogberg <devs+henrik+tomas@a...> Date: Mon, 20 Apr 2020 16:10:37 +0100 Subject: Time.xmlschema: Clarify error and docs It parses a (date)time, not a date. diff --git a/lib/time.rb b/lib/time.rb index f27bacd..b534c78 100644 --- a/lib/time.rb +++ b/lib/time.rb @@ -590,12 +590,12 @@ class Time https://github.com/ruby/ruby/blob/trunk/lib/time.rb#L590 end # - # Parses +date+ as a dateTime defined by the XML Schema and converts it to + # Parses +time+ as a dateTime defined by the XML Schema and converts it to # a Time object. The format is a restricted version of the format defined # by ISO 8601. # - # ArgumentError is raised if +date+ is not compliant with the format or if - # the Time class cannot represent specified date. + # ArgumentError is raised if +time+ is not compliant with the format or if + # the Time class cannot represent the specified time. # # See #xmlschema for more information on this format. # @@ -606,14 +606,14 @@ class Time https://github.com/ruby/ruby/blob/trunk/lib/time.rb#L606 # # You must require 'time' to use this method. # - def xmlschema(date) + def xmlschema(time) if /\A\s* (-?\d+)-(\d\d)-(\d\d) T (\d\d):(\d\d):(\d\d) (\.\d+)? (Z|[+-]\d\d(?::?\d\d)?)? - \s*\z/ix =~ date + \s*\z/ix =~ time year = $1.to_i mon = $2.to_i day = $3.to_i @@ -636,7 +636,7 @@ class Time https://github.com/ruby/ruby/blob/trunk/lib/time.rb#L636 self.local(year, mon, day, hour, min, sec, usec) end else - raise ArgumentError.new("invalid date: #{date.inspect}") + raise ArgumentError.new("invalid xmlschema format: #{time.inspect}") end end alias iso8601 xmlschema -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/