Skip to content

Commit

Permalink
fixed an xlsx format bug where formating containing [red] would get p…
Browse files Browse the repository at this point in the history
…icked up as date
  • Loading branch information
Eric Belec committed Mar 24, 2014
1 parent 7d403e3 commit 350157e
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 350157e

Please sign in to comment.