Class XSD::XSDGYear
In: lib/xsd/datatypes.rb
Parent: XSDAnySimpleType

Methods

_to_s   new   screen_data_str  

Included Modules

XSDDateTimeImpl

Constants

Type = QName.new(Namespace, GYearLiteral)

Public Class methods

[Source]

     # File lib/xsd/datatypes.rb, line 767
767:   def initialize(value = nil)
768:     init(Type, value)
769:   end

Private Instance methods

[Source]

     # 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

[Source]

     # 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

[Validate]