Class: Spreadsheet::Excel::Row
- Inherits:
-
Row
- Object
- Row
- Spreadsheet::Excel::Row
- Defined in:
- lib/roo/excel.rb,
lib/roo/excel.rb
Instance Method Summary collapse
-
#_date(data) ⇒ Object
:nodoc:.
-
#_datetime(data) ⇒ Object
:nodoc:.
Instance Method Details
#_date(data) ⇒ Object
:nodoc:
18 19 20 21 22 23 24 25 |
# File 'lib/roo/excel.rb', line 18 def _date data # :nodoc: return data if data.is_a?(Date) date = @worksheet.date_base + data.to_i if LEAP_ERROR > @worksheet.date_base date -= 1 end date end |
#_datetime(data) ⇒ Object
:nodoc:
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/roo/excel.rb', line 38 def _datetime data # :nodoc: return data if data.is_a?(DateTime) base = @worksheet.date_base date = base + data.to_f hour = (data % 1) * 24 min = (hour % 1) * 60 sec = ((min % 1) * 60).round min = min.floor hour = hour.floor if sec > 59 sec = 0 min += 1 end if min > 59 min = 0 hour += 1 end if hour > 23 hour = 0 date += 1 end if LEAP_ERROR > base date -= 1 end DateTime.new(date.year, date.month, date.day, hour, min, sec) end |