Sha256: a876f68a84dcb022d1e530fb552aa62db52be4e5cc4ddd3ff596fbc87f847932

Contents?: true

Size: 780 Bytes

Versions: 10

Compression:

Stored size: 780 Bytes

Contents

require 'date'

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

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

        private

        def create_date(base_date, value)
          date = base_date + value.to_i
          yyyy, mm, dd = date.strftime('%Y-%m-%d').split('-')

          ::Date.new(yyyy.to_i, mm.to_i, dd.to_i)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
roo-2.7.1 lib/roo/excelx/cell/date.rb
roo-2.7.0 lib/roo/excelx/cell/date.rb
roo-2.6.0 lib/roo/excelx/cell/date.rb
roo-2.5.1 lib/roo/excelx/cell/date.rb
roo-2.5.0 lib/roo/excelx/cell/date.rb
roo-2.4.0 lib/roo/excelx/cell/date.rb
roo-2.3.2 lib/roo/excelx/cell/date.rb
roo-2.3.1 lib/roo/excelx/cell/date.rb
roo-2.3.0 lib/roo/excelx/cell/date.rb
roo-2.2.0 lib/roo/excelx/cell/date.rb