diff --git a/lib/roo/excelx/cell/time.rb b/lib/roo/excelx/cell/time.rb index d661ab8d..9144425c 100644 --- a/lib/roo/excelx/cell/time.rb +++ b/lib/roo/excelx/cell/time.rb @@ -16,7 +16,7 @@ def initialize(value, formula, excelx_type, style, link, base_date, coordinate) end def formatted_value - formatter = @format.gsub(/#{TIME_FORMATS.keys.join('|')}/, TIME_FORMATS) + formatter = @format.downcase.gsub(/#{TIME_FORMATS.keys.join('|')}/, TIME_FORMATS) @datetime.strftime(formatter) end diff --git a/test/excelx/cell/test_time.rb b/test/excelx/cell/test_time.rb index 7619b3ae..11307c4a 100644 --- a/test/excelx/cell/test_time.rb +++ b/test/excelx/cell/test_time.rb @@ -16,7 +16,8 @@ def test_formatted_value ['h:mm:ss', '1:48:09'], ['mm:ss', '48:09'], ['[h]:mm:ss', '[1]:48:09'], - ['mmss.0', '4809.0'] # Cell::Time always get rounded to the nearest second. + ['mmss.0', '4809.0'], # Cell::Time always get rounded to the nearest second. + ['HH:MM:SS', '01:48:09'], # A capitalized example ].each do |style_format, result| cell = roo_time.new(value, nil, [:numeric_or_formula, style_format], 6, nil, base_date, nil) assert_equal result, cell.formatted_value, "Style=#{style_format} is not properly formatted"