[Bug]: DAYS360 (US method) ignores the end-of-month rule when the start date is the last day of February
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
Research direction
Start with DateTimeHelper.ts, especially toBasisUS, where the issue identifies the order of the February and end-of-month checks. Run the provided three DAYS360 examples and compare their results with the expected values. Done means the first two return 300 and 30 while the third still returns 60.
Written by the indexing model from the issue text.
Description
Description
With the default US (NASD) method, when the start date is the last day of February it becomes the 30th, and then an end date on the 31st also becomes the 30th (Excel DAYS360 documentation). HyperFormula applies the February adjustment after the start.day === 30 && end.day === 31 check, so the end date is not adjusted and the result is one day too large.
const { HyperFormula } = require('hyperformula')
const hf = HyperFormula.buildFromArray([[
'=DAYS360(DATE(2024,2,29), DATE(2024,12,31))',
'=DAYS360(DATE(2023,2,28), DATE(2023,3,31))',
'=DAYS360(DATE(2024,1,30), DATE(2024,3,31))',
]], { licenseKey: 'gpl-v3' })
console.log(hf.getSheetValues(0)[0])
Actual: [ 301, 31, 60 ]
Expected (Excel, LibreOffice): [ 300, 30, 60 ]
The third call (start already on the 30th) returns 60, which shows the end-of-month rule works when the start date did not need the February adjustment.
Cause: DateTimeHelper.toBasisUS in DateTimeHelper.ts checks start.day === 30 && end.day === 31 before setting start.day = 30 for the last day of February.
Video or screenshots
N/A
Demo
https://gist.github.com/trackoor/956d3d7fa69b41acdf9f9bd48071b52e
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/
- Dominant language
- TypeScript
- Stars
- 2.8k
- Forks
- 175
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 22
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from handsontable/hyperformula
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
handsontable/hyperformula#1803 ·
Maintainers usually reply within 1 day
-
numberToSimpleDate returns day 0 for 31 December of some years when leapYear1900 is truePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
handsontable/hyperformula#1793 ·
Maintainers usually reply within 1 day
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
handsontable/hyperformula#1745 ·
Maintainers usually reply within 1 day
-
Bug Impact: Low
Difficulty 1/5 1-3 hours Newbie friendliness 68/100
handsontable/hyperformula#1641 ·
Maintainers usually reply within 1 day
-
Bug
Difficulty 3/5 1-2 days Newbie friendliness 74/100
handsontable/hyperformula#1878 ·
Maintainers usually reply within 1 day
All issues in handsontable/hyperformula
Similar issues
-
area:frontend kind:bug priority:p2 ready
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
RunestoneInteractive/rs#1661 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
capricorn86/happy-dom#2594 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
ehmpathy/rhachet-roles-ehmpathy#1294 ·
Maintainers usually reply within 1 day