summaryrefslogtreecommitdiffstats
path: root/test/excelx/cell/test_datetime.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_datetime.rb
Import Upstream version 2.7.1upstream/2.7.1
Diffstat (limited to 'test/excelx/cell/test_datetime.rb')
-rw-r--r--test/excelx/cell/test_datetime.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/excelx/cell/test_datetime.rb b/test/excelx/cell/test_datetime.rb
new file mode 100644
index 0000000..425830b
--- /dev/null
+++ b/test/excelx/cell/test_datetime.rb
@@ -0,0 +1,45 @@
+require 'test_helper'
+
+class TestRooExcelxCellDateTime < Minitest::Test
+ def test_cell_value_is_datetime
+ cell = datetime.new('30000.323212', nil, ['mm-dd-yy'], nil, nil, base_date, nil)
+ assert_kind_of ::DateTime, cell.value
+ end
+
+ def test_cell_type_is_datetime
+ cell = datetime.new('30000.323212', nil, [], nil, nil, base_date, nil)
+ assert_equal :datetime, cell.type
+ end
+
+ def test_standard_formatted_value
+ [
+ ['mm-dd-yy', '01-25-15'],
+ ['d-mmm-yy', '25-JAN-15'],
+ ['d-mmm ', '25-JAN'],
+ ['mmm-yy', 'JAN-15'],
+ ['m/d/yy h:mm', '1/25/15 8:15']
+ ].each do |format, formatted_value|
+ cell = datetime.new '42029.34375', nil, [format], nil, nil, base_date, nil
+ assert_equal formatted_value, cell.formatted_value
+ end
+ end
+
+ def test_custom_formatted_value
+ [
+ ['yyyy/mm/dd hh:mm:ss', '2015/01/25 08:15:00'],
+ ['h:mm:ss000 mm/yy', '8:15:00000 01/15'],
+ ['mmm yyy', '2015-01-25 08:15:00']
+ ].each do |format, formatted_value|
+ cell = datetime.new '42029.34375', nil, [format], nil, nil, base_date, nil
+ assert_equal formatted_value, cell.formatted_value
+ end
+ end
+
+ def datetime
+ Roo::Excelx::Cell::DateTime
+ end
+
+ def base_date
+ Date.new(1899, 12, 30)
+ end
+end