Skip to content

Commit

Permalink
Merge pull request #120 from EricBel/master
Browse files Browse the repository at this point in the history
fixed an xlsx format bug - format containing [red] was converted to date
  • Loading branch information
Empact committed Mar 27, 2014
2 parents 643a1fb + 350157e commit 53aab98
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.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def to_type(format)
type
elsif format.include?('#')
:float
elsif format.include?('d') || format.include?('y')
elsif !format.match(/d+(?![\]])/).nil? || format.include?('y')
if format.include?('h') || format.include?('s')
:datetime
else
Expand Down
3 changes: 2 additions & 1 deletion spec/lib/roo/excelx/format_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
'dd/mmm/yy\\ hh:mm' => :datetime,
'dd/mmm/yy' => :date, # 2011-05-21
'yyyy-mm-dd' => :date, # 2011-09-16
'yyyy-mm-dd;@' => :date
'yyyy-mm-dd;@' => :date,
'#0_);[Red]\(0\)' => :float
}.each do |format, type|
it "translates #{format} to #{type}" do
Roo::Excelx::Format.to_type(format).should == type
Expand Down

0 comments on commit 53aab98

Please sign in to comment.