method
_xmlschema
v1_9_1_378 -
Show latest stable
- Class:
Date
_xmlschema(str)public
No documentation available.
# File lib/date/format.rb, line 1130
def self._xmlschema(str) # :nodoc:
if /\A\s*(-?\d{4,})(?:-(\d{2})(?:-(\d{2}))?)?
(?:t
(\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?)?
(z|[-+]\d{2}:\d{2})?\s*\z/x =~ str
e = Format::Bag.new
e.year = $1.to_i
e.mon = $2.to_i if $2
e.mday = $3.to_i if $3
e.hour = $4.to_i if $4
e.min = $5.to_i if $5
e.sec = $6.to_i if $6
e.sec_fraction = Rational($7.to_i, 10**$7.size) if $7
if $8
e.zone = $8
e.offset = zone_to_diff($8)
end
e.to_hash
elsif /\A\s*(\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?
(z|[-+]\d{2}:\d{2})?\s*\z/x =~ str
e = Format::Bag.new
e.hour = $1.to_i if $1
e.min = $2.to_i if $2
e.sec = $3.to_i if $3
e.sec_fraction = Rational($4.to_i, 10**$4.size) if $4
if $5
e.zone = $5
e.offset = zone_to_diff($5)
end
e.to_hash
elsif /\A\s*(?:--(\d{2})(?:-(\d{2}))?|---(\d{2}))
(z|[-+]\d{2}:\d{2})?\s*\z/x =~ str
e = Format::Bag.new
e.mon = $1.to_i if $1
e.mday = $2.to_i if $2
e.mday = $3.to_i if $3
if $4
e.zone = $4
e.offset = zone_to_diff($4)
end
e.to_hash
end
end