aboutsummaryrefslogtreecommitdiffstats
path: root/lib/roo/excelx/cell/date.rb
blob: 8627bc5783a213eba87ce02431c44c58423fdf93 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'date'

module Roo
  class Excelx
    class Cell
      class Date < Roo::Excelx::Cell::DateTime
        attr_reader :value, :formula, :format, :cell_type, :cell_value, :coordinate

        attr_reader_with_default default_type: :date

        def initialize(value, formula, excelx_type, style, link, base_date, coordinate)
          # NOTE: Pass all arguments to the parent class, DateTime.
          super
          @format = excelx_type.last
          @value = link ? Roo::Link.new(link, value) : create_date(base_date, value)
        end

        private

        def create_datetime(_,_);  end

        def create_date(base_date, value)
          base_date + value.to_i
        end
      end
    end
  end
end