roo-rb / roo

Roo provides an interface to spreadsheets of several sorts.
MIT License
2.8k stars 501 forks source link

Incorrect date parsing in xlsx files to Sat, 15 Jul 1905 #593

Open Ankush-yubi opened 1 year ago

Ankush-yubi commented 1 year ago

Steps to reproduce

xlsx = Roo::Excelx.new("./date_file.xlsx") xlsx.each_row_streaming do |row| puts row.inspect end

Issue

<Roo::Excelx::Cell::Date:0x00000001320b7ba0 @cell_value="2023-11-01", @cell_type=[:numeric_or_formula, "yyyy\-mm\-dd"], @coordinate=[7, 6], @value=Sat, 15 Jul 1905, @format="yyyy\-mm\-dd", @style=8>

2023-11-01 value incorrectly parsed to Sat, 15 Jul 1905.

System configuration

Roo version: (2.9.0) Ruby version: 3.0.4

ssunday commented 1 year ago

Also experiencing

1990eam commented 1 year ago

Don't know if it's related but I'm also having an issue where 08/04/2023 is parsed as 2023-04-08. Why and how could it be prevented?

Edit: found where the string is casted to a Date object with the mentioned format in the gem files (lib/roo/excelx/cell.rb). Since it's already casting it into a Date object I'm just reformatting it again to the desired format.