| Class | XSD::XSDGYear |
| In: |
lib/xsd/datatypes.rb
|
| Parent: | XSDAnySimpleType |
| Type | = | QName.new(Namespace, GYearLiteral) |
# File lib/xsd/datatypes.rb, line 767
767: def initialize(value = nil)
768: init(Type, value)
769: end
# File lib/xsd/datatypes.rb, line 786
786: def _to_s
787: year = (@data.year > 0) ? @data.year : @data.year - 1
788: s = format('%.4d', year)
789: add_tz(s)
790: end
# File lib/xsd/datatypes.rb, line 773
773: def screen_data_str(t)
774: /^([+\-]?\d{4,})(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
775: unless Regexp.last_match
776: raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
777: end
778: year = $1.to_i
779: if year < 0
780: year += 1
781: end
782: zonestr = $2
783: DateTime.civil(year, 1, 1, 0, 0, 0, tz2of(zonestr))
784: end