Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
Time.iso8601
(::String date) -> ::Time
iso8601(time)
lib/time.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/time.rb, line 629
def xmlschema(time)
pattern = /\A\s*
(-?\d+)-(\d\d)-(\d\d)
T
(\d\d):(\d\d):(\d\d)
(\.\d+)?
(Z|[+-]\d\d(?::?\d\d)?)?
\s*\z/ix
_xmlschema(pattern, time) or
raise ArgumentError.new("invalid xmlschema format: #{time.inspect}")
end
Alias of .xmlschema
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 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.
Example
require 'time' Time.xmlschema("2011-10-05T22:26:12-04:00") #=> 2011-10-05 22:26:12-04:00
You must require ‘time’ to use this method.