summaryrefslogtreecommitdiffstats
path: root/test/excelx/cell/test_date.rb
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2017-06-12 03:37:11 -0400
committerLibravatarUnit 193 <unit193@ubuntu.com>2017-06-12 03:37:11 -0400
commit8280a21a23d44aa90177e2bc041d0b8dc8556f4b (patch)
treedadef7ee085c0e990a5070bd41b6a5b98c97f4fd /test/excelx/cell/test_date.rb
Import Upstream version 2.7.1upstream/2.7.1
Diffstat (limited to 'test/excelx/cell/test_date.rb')
-rw-r--r--test/excelx/cell/test_date.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/excelx/cell/test_date.rb b/test/excelx/cell/test_date.rb
new file mode 100644
index 0000000..7bd046b
--- /dev/null
+++ b/test/excelx/cell/test_date.rb
@@ -0,0 +1,38 @@
+require 'test_helper'
+
+class TestRooExcelxCellDate < Minitest::Test
+ def date_cell
+ Roo::Excelx::Cell::Date
+ end
+
+ def base_date
+ ::Date.new(1899, 12, 30)
+ end
+
+ def base_date_1904
+ ::Date.new(1904, 01, 01)
+ end
+
+ def test_handles_1904_base_date
+ cell = date_cell.new('41791', nil, [:numeric_or_formula, 'mm-dd-yy'], 6, nil, base_date_1904, nil)
+ assert_equal ::Date.new(2018, 06, 02), cell.value
+ end
+
+ def test_formatted_value
+ cell = date_cell.new('41791', nil, [:numeric_or_formula, 'mm-dd-yy'], 6, nil, base_date, nil)
+ assert_equal '06-01-14', cell.formatted_value
+
+ cell = date_cell.new('41791', nil, [:numeric_or_formula, 'yyyy-mm-dd'], 6, nil, base_date, nil)
+ assert_equal '2014-06-01', cell.formatted_value
+ end
+
+ def test_value_is_date
+ cell = date_cell.new('41791', nil, [:numeric_or_formula, 'mm-dd-yy'], 6, nil, base_date, nil)
+ assert_kind_of ::Date, cell.value
+ end
+
+ def test_value
+ cell = date_cell.new('41791', nil, [:numeric_or_formula, 'mm-dd-yy'], 6, nil, base_date, nil)
+ assert_equal ::Date.new(2014, 06, 01), cell.value
+ end
+end