class XSD::XSDDate

Constants

Type

Public Class Methods

new(value = nil) click to toggle source
# File lib/xsd/datatypes.rb, line 719
def initialize(value = nil)
  init(Type, value)
end

Private Instance Methods

_to_s() click to toggle source
# File lib/xsd/datatypes.rb, line 740
def _to_s
  year = (@data.year > 0) ? @data.year : @data.year - 1
  s = format('%.4d-%02d-%02d', year, @data.mon, @data.mday)
  add_tz(s)
end
screen_data_str(t) click to toggle source
# File lib/xsd/datatypes.rb, line 725
def screen_data_str(t)
  /^([+\-]?\d{4,})-(\d\d)-(\d\d)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
  unless Regexp.last_match
    raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
  end
  year = $1.to_i
  if year < 0
    year += 1
  end
  mon = $2.to_i
  mday = $3.to_i
  zonestr = $4
  DateTime.civil(year, mon, mday, 0, 0, 0, tz2of(zonestr))
end