| Class | XSD::XSDGYearMonth |
| In: |
lib/xsd/datatypes.rb
|
| Parent: | XSDAnySimpleType |
| Type | = | QName.new(Namespace, GYearMonthLiteral) |
# File lib/xsd/datatypes.rb, line 736
736: def initialize(value = nil)
737: init(Type, value)
738: end
# File lib/xsd/datatypes.rb, line 756
756: def _to_s
757: year = (@data.year > 0) ? @data.year : @data.year - 1
758: s = format('%.4d-%02d', year, @data.mon)
759: add_tz(s)
760: end
# File lib/xsd/datatypes.rb, line 742
742: def screen_data_str(t)
743: /^([+\-]?\d{4,})-(\d\d)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
744: unless Regexp.last_match
745: raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
746: end
747: year = $1.to_i
748: if year < 0
749: year += 1
750: end
751: mon = $2.to_i
752: zonestr = $3
753: DateTime.civil(year, mon, 1, 0, 0, 0, tz2of(zonestr))
754: end