[Bug]: DAYS360 (US method) ignores the end-of-month rule when the start date is the last day of February

オープン 初心者向け
#1,879 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
node.js, typescript
領域
backend, data

調査の方向性

DateTimeHelper.ts、特に issue で2月と月末のチェック順序が示されている toBasisUS から始めてください。提供された3つの DAYS360 の例を実行し、結果を期待値と比較してください。最初の2つがそれぞれ300と30を返し、3つ目が引き続き60を返せば完了です。

索引モデルが issue の本文から書いたものです。

説明

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/

主要言語
TypeScript
スター
2.8k
フォーク
175
平均マージ
2日 7時間
マージ済み PR(30日)
22

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

handsontable/hyperformula のほかの issue

handsontable/hyperformula の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。