Ruby 3.2 removed Object#=~ making it impossible to write Date objects
Closed this issue · 3 comments
grk commented
Reproduction steps:
require 'write_xlsx'
require 'date'
workbook = WriteXLSX.new(StringIO.new)
worksheet = workbook.add_worksheet
worksheet.write(0, 0, Date.today)
This works on 3.1, but on 3.2 fails with the following error:
irb(main):006:0> worksheet.write(0, 0, Date.today)
/Users/grk/.asdf/installs/ruby/3.2.1/lib/ruby/gems/3.2.0/gems/write_xlsx-1.10.1/lib/write_xlsx/worksheet.rb:909:in `write': undefined method `=~' for #<Date: 2023-02-15 ((2459991j,0s,0n),+0s,2299161j)> (NoMethodError)
cxn03651 commented
Thank you for your report.
fixed version v1.10.2 will be released soon.
FYI:
We have Worksheet#write_date_time method which can write date/time in several format.
see https://cxn03651.github.io/write_xlsx/worksheet.html#write_date_time
gsinclair commented
Thank you so much for fixing this bug. It was frustrating to encounter this strange error when running my program. Fortunately the fix was simple: bundle update write_xlsx
.