Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 32 additions & 22 deletions lib/time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -664,31 +664,41 @@ def rfc3339(time)

private

def _xmlschema(pattern, time)
if pattern =~ time
year = $1.to_i
mon = $2.to_i
day = $3.to_i
hour = $4.to_i
min = $5.to_i
sec = $6.to_i
usec = 0
if $7
usec = Rational($7) * 1000000
if RUBY_VERSION >= "3.2"
def _xmlschema(pattern, time)
if pattern.match?(time)
new(time)
else
raise ArgumentError.new("invalid xmlschema format: #{time.inspect}")
end
if $8
zone = $8
off = zone_offset(zone)
year, mon, day, hour, min, sec =
apply_offset(year, mon, day, hour, min, sec, off)
t = self.utc(year, mon, day, hour, min, sec, usec)
force_zone!(t, zone, off)
t
end
else
def _xmlschema(pattern, time)
if pattern =~ time
year = $1.to_i
mon = $2.to_i
day = $3.to_i
hour = $4.to_i
min = $5.to_i
sec = $6.to_i
usec = 0
if $7
usec = Rational($7) * 1000000
end
if $8
zone = $8
off = zone_offset(zone)
year, mon, day, hour, min, sec =
apply_offset(year, mon, day, hour, min, sec, off)
t = self.utc(year, mon, day, hour, min, sec, usec)
force_zone!(t, zone, off)
t
else
self.local(year, mon, day, hour, min, sec, usec)
end
else
self.local(year, mon, day, hour, min, sec, usec)
raise ArgumentError.new("invalid xmlschema format: #{time.inspect}")
end
else
raise ArgumentError.new("invalid xmlschema format: #{time.inspect}")
end
end

Expand Down