Description
Description
Excel truncates a non-integer months argument in EDATE and EOMONTH (Excel EDATE documentation: "If months is not an integer, it is truncated."). HyperFormula returns #NUM! ("Date outside of bounds.") for any fractional value, including ones produced by arithmetic such as =EDATE(A1, B1/2).
const { HyperFormula } = require('hyperformula')
const hf = HyperFormula.buildFromArray([[
'=EDATE(DATE(2024,1,15), 1.5)',
'=EOMONTH(DATE(2024,1,15), 1.5)',
'=EOMONTH(DATE(2024,1,15), -0.5)',
'=EDATE(DATE(2024,1,15), 1)',
]], { licenseKey: 'gpl-v3' })
console.log(hf.getSheetValues(0)[0].map(v => v?.value ?? v))Actual: [ '#NUM!', '#NUM!', '#NUM!', 45337 ]
Expected (Excel, LibreOffice): [ 45337, 45351, 45322, 45337 ] (2024-02-15, 2024-02-29, 2024-01-31, 2024-02-15)
Cause: edate and eomonth in DateTimePlugin.ts call offsetMonth directly with the fractional months value without applying Math.trunc, so the resulting month is not an integer and dateToNumber fails.
Video or screenshots
N/A
Demo
https://gist.github.com/trackoor/dc51f7bfdfd833e3b7268c00203bf1b3
HyperFormula version
3.5.0 (npm), also master (187dfa16) and develop (5a6eb09)
Your framework
None (Node.js)
Your environment
Node.js v26.13.0 on Linux
Credit: https://ucsbplse.github.io/
Activity