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

Đang mở Phù hợp với người mới
#1,879 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
node.js, typescript
Lĩnh vực
backend, data

Hướng nghiên cứu

Bắt đầu với DateTimeHelper.ts, đặc biệt là toBasisUS, nơi issue xác định thứ tự kiểm tra tháng 2 và cuối tháng. Chạy ba ví dụ DAYS360 được cung cấp và so sánh kết quả với các giá trị mong đợi. Công việc được coi là hoàn tất khi hai ví dụ đầu tiên lần lượt trả về 300 và 30, còn ví dụ thứ ba vẫn trả về 60.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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/

Ngôn ngữ chính
TypeScript
Star
2.8k
Fork
175
Merge trung bình
2 ngày 7 giờ
Pull request đã merge (30 ngày)
22

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của handsontable/hyperformula

Tất cả issue của handsontable/hyperformula

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.