xl icon indicating copy to clipboard operation
xl copied to clipboard

Dates are computed wrong if using the 1900 compatibility mode

Open igordsm opened this issue 2 years ago • 1 comments

I encountered a bug when dealing with dates in a .xlsx file created using LibreOffice. Date computed by xl are usually 2 days off the real date.

According to this site, the formula used to compute number of days after the epoch is wrong. I can send a PR with a correct implementation and unit tests for this, if the author accepts this bug.

How to reproduce

Create an empty sheet with only one cell with the date 2023-12-22

Run the following code

import xl

let w = xl.load("test.xlsx")
let s = w.sheet(0)

echo "Days after the epoch ", $s.cell("A1").value
echo "Current date ", $s.cell("A1").date

The output will be

Days after the epoch 45282
Current date 2023-12-24T00:06:28-03:00

igordsm avatar Dec 22 '23 16:12 igordsm

PR is welcome

khchen avatar Dec 24 '23 16:12 khchen