Method: Time#to_excel

Defined in:
lib/to_xl.rb

#to_excelObject Also known as: to_xl



5
6
7
8
9
10
11
12
# File 'lib/to_xl.rb', line 5

def to_excel
  @seconds_in_day ||= 24 * 60 * 60
  @excel_days_offset ||= 25569
  @offset_gmt = (self.hour > self.gmtime.hour) ? true : false  # Excel dates are on GMT time, so we have to go back a day if this is calculated on one day in our time zone and another on GMT.
  excel_date = (self.to_i/@seconds_in_day) + @excel_days_offset
  excel_date -= 1 if @offset_gmt # Excel dates are on GMT time, so we have to go back a day if this is calculated on one day in our time zone and another on GMT.
  excel_date
end