lib/spreadsheet/excel/row.rb in spreadsheet-0.6.3.1 vs lib/spreadsheet/excel/row.rb in spreadsheet-0.6.4

- old
+ new

@@ -43,22 +43,20 @@ end end private def _date data # :nodoc: return data if data.is_a?(Date) - date = @worksheet.date_base + data.to_i - if date > LEAP_ERROR - date -= 1 - end - date + datetime = _datetime data + Date.new datetime.year, datetime.month, datetime.day end def _datetime data # :nodoc: return data if data.is_a?(DateTime) - date = _date data + base = @worksheet.date_base + date = base + data.to_f hour = (data % 1) * 24 min = (hour % 1) * 60 - sec = ((min % 1) * 60).round + sec = ((min % 1) * 60).round min = min.floor hour = hour.floor if sec > 59 sec = 0 min += 1 @@ -66,9 +64,12 @@ if min > 59 hour += 1 end if hour > 23 date += 1 + end + if LEAP_ERROR > base + date -= 1 end DateTime.new(date.year, date.month, date.day, hour, min, sec) end def enriched_data idx, data # :nodoc: res = nil