In: |
xsd/datatypes.rb
|
# File xsd/datatypes.rb, line 527 def _set(t) set_datetime_init(t) if (t.is_a?(Date)) @data = t elsif (t.is_a?(Time)) sec, min, hour, mday, month, year = t.to_a[0..5] diffday = t.usec.to_r / 1000000 / SecInDay of = t.utc_offset.to_r / SecInDay @data = DateTime.civil(year, month, mday, hour, min, sec, of) @data += diffday else set_str(t) end end
# File xsd/datatypes.rb, line 517 def of2tz(offset) diffmin = offset * 24 * 60 if diffmin.zero? 'Z' else ((diffmin < 0) ? '-' : '+') << format('%02d:%02d', (diffmin.abs / 60.0).to_i, (diffmin.abs % 60.0).to_i) end end
# File xsd/datatypes.rb, line 484 def to_time begin if @data.offset * SecInDay == Time.now.utc_offset d = @data usec = (d.sec_fraction * SecInDay * 1000000).round Time.local(d.year, d.month, d.mday, d.hour, d.min, d.sec, usec) else d = @data.newof usec = (d.sec_fraction * SecInDay * 1000000).round Time.gm(d.year, d.month, d.mday, d.hour, d.min, d.sec, usec) end rescue ArgumentError nil end end