Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Changeset 1567

Show
Ignore:
Timestamp:
06/05/05 16:29:14 (3 years ago)
Author:
nahi
Message:

simplify to_datetime method checking for 1.9.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/xsd/datatypes.rb

    r1559 r1567  
    561561  def screen_data(t) 
    562562    # convert t to a DateTime as an internal representation. 
    563     if t.is_a?(DateTime) 
     563    if t.respond_to?(:to_datetime)      # 1.9 or later 
     564      t.to_datetime 
     565    elsif t.is_a?(DateTime) 
    564566      t 
    565567    elsif t.is_a?(Date) 
    566       if t.respond_to?(:to_datetime)    # from 1.9 
    567         t.to_datetime 
    568       else 
    569         t = screen_data_str(t) 
    570         t <<= 12 if t.year < 0 
    571         t 
    572       end 
     568      t = screen_data_str(t) 
     569      t <<= 12 if t.year < 0 
     570      t 
    573571    elsif t.is_a?(Time) 
    574       sec, min, hour, mday, month, year = t.to_a[0..5] 
    575       diffday = t.usec.to_r / 1000000 / SecInDay 
     572      jd = DateTime.civil_to_jd(t.year, t.mon, t.mday, DateTime::ITALY) 
     573      fr = DateTime.time_to_day_fraction(t.hour, t.min, [t.sec, 59].min) + 
     574        t.usec.to_r / 1000000 / SecInDay 
    576575      of = t.utc_offset.to_r / SecInDay 
    577       data = DateTime.civil(year, month, mday, hour, min, sec, of) 
    578       data += diffday 
    579       data 
     576      DateTime.new0(DateTime.jd_to_ajd(jd, fr, of), of, DateTime::ITALY) 
    580577    else 
    581578      screen_data_str(t)