diff options
author | Jean Boussier <[email protected]> | 2024-09-05 10:06:01 +0200 |
---|---|---|
committer | git <[email protected]> | 2024-09-05 22:37:35 +0000 |
commit | 72acd1c8b1003467d838728a5c113a127a441f6b () | |
tree | 1b5df6cf3b57b4e9e04f8a337f5680f44bc7fdf3 /lib/time.rb | |
parent | f250296efaa7ea3e929eeaecfecd29e5cfe13de3 (diff) |
[ruby/time] Do not redefine Time#xmlschema if it already exists
[Feature #20707] Ruby 3.4 will define this method natively, so the time gem shouldn't redefine it with a slower version. https://.com/ruby/time/commit/f05099ce38
-rw-r--r-- | lib/time.rb | 59 |
1 files changed, 30 insertions, 29 deletions
@@ -695,35 +695,36 @@ class Time getutc.strftime('%a, %d %b %Y %T GMT') end - # - # Returns a string which represents the time as a dateTime defined by XML - # Schema: - # - # CCYY-MM-DDThh:mm:ssTZD - # CCYY-MM-DDThh:mm:ss.sssTZD - # - # where TZD is Z or [+-]hh:mm. - # - # If self is a UTC time, Z is used as TZD. [+-]hh:mm is used otherwise. - # - # +fraction_digits+ specifies a number of digits to use for fractional - # seconds. Its default value is 0. - # - # require 'time' - # - # t = Time.now - # t.iso8601 # => "2011-10-05T22:26:12-04:00" - # - # You must require 'time' to use this method. - # - 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 iso8601 xmlschema end - |