Sha256: 60d55fdca8f42069e2c0d5c7978a00e83b7d4a4e1eb4ff25c69b7064839853b3

Contents?: true

Size: 998 Bytes

Versions: 1

Compression:

Stored size: 998 Bytes

Contents

require "date"
require "xsd/datatypes"

# Fix bug in "soap4r-ng" gem, where representation of "xsd:gYear" datatype is,
# incorrectly, delegated to `DateTime.to_datetime` in first clause of
# `XSD::XSDDateTimeImpl#screen_data` instance method (c.f.,
# https://github.com/rubyjedi/soap4r/blob/master/lib/xsd/datatypes.rb#L579).

XSD::XSDDateTimeImpl.class_eval do
  undef :screen_data
end

XSD::XSDDateTimeImpl.send(:define_method, :screen_data) do |t|
  if t.is_a?(::DateTime)
    t
  elsif t.is_a?(::Date)
    t = send(:screen_data_str, t)
    t <<= 12 if t.year < 0
    t
  elsif t.is_a?(::Time)
    jd = ::DateTime.send(:civil_to_jd, t.year, t.mon, t.mday, ::DateTime::ITALY)
    fr = ::DateTime.send(:time_to_day_fraction, t.hour, t.min, [t.sec, 59].min) + t.usec.to_r / XSD::XSDDateTimeImpl::DayInMicro
    of = t.utc_offset.to_r / XSD::XSDDateTimeImpl::DayInSec
    ::DateTime.new!(::DateTime.send(:jd_to_ajd, jd, fr, of), of, ::DateTime::ITALY)
  else
    send(:screen_data_str, t)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
building_sync_rails-0.1.0 config/initializers/soap4r_xsd_datatypes_fix.rb