Skip to content

Commit

Permalink
Merge 2ccb6f5 into 62b033c
Browse files Browse the repository at this point in the history
  • Loading branch information
pacoguzman committed Jan 3, 2018
2 parents 62b033c + 2ccb6f5 commit 9760893
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/roo/excelx/cell/time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion test/excelx/cell/test_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 9760893

Please sign in to comment.