lib/roo/excel.rb
def read_cell_date_or_time(row, idx)
    cell = read_cell_content(row, idx)
    cell = cell.to_s.to_f
    if cell < 1.0
      value_type = :time
      f = cell*24.0*60.0*60.0
      secs = f.round
      h = (secs / 3600.0).floor
      secs = secs - 3600*h
      m = (secs / 60.0).floor
      secs = secs - 60*m
      s = secs
      value = h*3600+m*60+s
    else
      if row.at(idx).class == Spreadsheet::Formula
        datetime = row.send(:_datetime, cell)
      else
        datetime = row.datetime(idx)
      end
      if datetime.hour != 0 or
          datetime.min != 0 or
          datetime.sec != 0
        value_type = :datetime
        value = datetime
      else
        value_type = :date
        if row.at(idx).class == Spreadsheet::Formula
          value = row.send(:_date, cell)
        else
          value = row.date(idx)
        end
        value = sprintf("%04d-%02d-%02d",value.year,value.month,value.day)
      end
    end
    return value_type, value
  end
# Read the date-time cell and convert to,
# the date-time values for Roo
Read the date-time cell and convert to,
the date-time values for Roo
Read the date - time cell and convert to the date - time values for Roo
def read_cell_date_or_time(row, idx)
    cell = read_cell_content(row, idx)
    cell = cell.to_s.to_f
    if cell < 1.0
      value_type = :time
      f = cell*24.0*60.0*60.0
      secs = f.round
      h = (secs / 3600.0).floor
      secs = secs - 3600*h
      m = (secs / 60.0).floor
      secs = secs - 60*m
      s = secs
      value = h*3600+m*60+s
    else
      if row.at(idx).class == Spreadsheet::Formula
        datetime = row.send(:_datetime, cell)
      else
        datetime = row.datetime(idx)
      end
      if datetime.hour != 0 or
          datetime.min != 0 or
          datetime.sec != 0
        value_type = :datetime
        value = datetime
      else
        value_type = :date
        if row.at(idx).class == Spreadsheet::Formula
          value = row.send(:_date, cell)
        else
          value = row.date(idx)
        end
        value = sprintf("%04d-%02d-%02d",value.year,value.month,value.day)
      end
    end
    return value_type, value
  end
def read_cell_date_or_time ( row , idx ) cell = read_cell_content ( row , idx ) cell = cell . to_s . to_f if cell < 1.0 value_type = :time f = cell * 24.0 * 60.0 * 60.0 secs = f . round h = ( secs / 3600.0 ) . floor secs = secs - 3600 * h m = ( secs / 60.0 ) . floor secs = secs - 60 * m s = secs value = h * 3600 + m * 60 + s else if row . at ( idx ) . class == Spreadsheet :: Formula datetime = row . send ( :_datetime , cell ) else datetime = row . datetime ( idx ) end if datetime . hour != 0 or datetime . min != 0 or datetime . sec != 0 value_type = :datetime value = datetime else value_type = :date if row . at ( idx ) . class == Spreadsheet :: Formula value = row . send ( :_date , cell ) else value = row . date ( idx ) end value = sprintf ( "%04d-%02d-%02d" , value . year , value . month , value . day ) end end return value_type , value end
Read the date-time cell and convert to,
the date-time values for Roo
Read the date - time cell and convert to the date - time values for Roo
row
idx