instance method
Time#iso8601
(?::Integer fraction_digits) -> ::String
iso8601(fraction_digits=0)
lib/time.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/time.rb, line 724
def xmlschema(fraction_digits=0)
fraction_digits = fraction_digits.to_i
s = strftime("%FT%T")
if fraction_digits > 0
s << strftime(".%#{fraction_digits}N")
end
s << (utc? ? 'Z' : strftime("%:z"))
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.
Ruby version changes
-
3.4
-
Time#xmlschema, and itsTime#iso8601alias have been moved into the coreTimeclass while previously it was an extension provided by thetimegem. [Feature #20707]
-