diff options
| author | 2022-03-19 21:47:36 -0400 | |
|---|---|---|
| committer | 2022-03-19 21:47:36 -0400 | |
| commit | f5fb17e5a64b215644bc104f099dad8c2f10c37d (patch) | |
| tree | 6ad047451881cfe94f3aabe1c33b404c134a5085 /spec/lib/roo/excelx | |
| parent | 9e07e8cd4836ddc89accdb7b20152c9a4f06fd03 (diff) | |
New upstream version 2.9.0.upstream/2.9.0
Diffstat (limited to 'spec/lib/roo/excelx')
| -rw-r--r-- | spec/lib/roo/excelx/cell/time_spec.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/lib/roo/excelx/cell/time_spec.rb b/spec/lib/roo/excelx/cell/time_spec.rb new file mode 100644 index 0000000..214443f --- /dev/null +++ b/spec/lib/roo/excelx/cell/time_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper'
+
+RSpec.describe Roo::Excelx::Cell::Time do
+ it "should set the cell value to the correct number of seconds" do
+ value = 0.05513888888888888 # '1:19:24'
+ excelx_type = [:numeric_or_formula, "h:mm:ss"]
+ base_timestamp = Date.new(1899, 12, 30).to_time.to_i
+ time_cell = Roo::Excelx::Cell::Time.new(value, nil, excelx_type, 1, nil, base_timestamp, nil)
+ expect(time_cell.value).to eq(1*60*60 + 19*60 + 24) # '1:19:24' in seconds
+ # use case from https://github.com/roo-rb/roo/issues/310
+ value = 0.523761574074074 # '12:34:13' in seconds
+ time_cell = Roo::Excelx::Cell::Time.new(value, nil, excelx_type, 1, nil, base_timestamp, nil)
+ expect(time_cell.value).to eq(12*60*60 + 34*60 + 13) # 12:34:13 in seconds
+ end
+end
\ No newline at end of file |
