diff --git a/lib/roo/excelx.rb b/lib/roo/excelx.rb index 31431ebd..bf902083 100644 --- a/lib/roo/excelx.rb +++ b/lib/roo/excelx.rb @@ -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 diff --git a/spec/lib/roo/excelx/format_spec.rb b/spec/lib/roo/excelx/format_spec.rb index 815fbc26..488d2379 100644 --- a/spec/lib/roo/excelx/format_spec.rb +++ b/spec/lib/roo/excelx/format_spec.rb @@ -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