We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The add/subtract function behaves incorrectly on leap year.
[dayjs 1.11.12] console.log(dayjs('2023-01-01').add(dayjs.duration(365, 'day')).toDate()); // Mon Jan 01 2024 00:00:00 GMT+0900 console.log(dayjs('2024-01-01').add(dayjs.duration(365, 'day')).toDate()); // Wed Jan 01 2025 00:00:00 GMT+0900 <-- wrong console.log(dayjs('2025-01-01').add(dayjs.duration(365, 'day')).toDate()); // Thu Jan 01 2026 00:00:00 GMT+0900
console.log(dayjs('2024-01-01').subtract(dayjs.duration(365, 'day')).toDate()); // Sun Jan 01 2023 00:00:00 GMT+0900 console.log(dayjs('2025-01-01').subtract(dayjs.duration(365, 'day')).toDate()); // Mon Jan 01 2024 00:00:00 GMT+0900 <-- wrong console.log(dayjs('2026-01-01').subtract(dayjs.duration(365, 'day')).toDate()); // Wed Jan 01 2025 00:00:00 GMT+0900
[moment.js] console.log(moment('2023-01-01').add(moment.duration(365, 'day')).toDate()); // Mon Jan 01 2024 00:00:00 GMT+0900 console.log(moment('2024-01-01').add(moment.duration(365, 'day')).toDate()); // Tue Dec 31 2024 00:00:00 GMT+0900 <-- correct console.log(moment('2025-01-01').add(moment.duration(365, 'day')).toDate()); // Wed Jan 01 2025 00:00:00 GMT+0900
console.log(moment('2024-01-01').subtract(moment.duration(365, 'day')).toDate()); // Sun Jan 01 2023 00:00:00 GMT+0900 console.log(moment('2025-01-01').subtract(moment.duration(365, 'day')).toDate()); // Tue Jan 02 2024 00:00:00 GMT+0900 <-- correct console.log(moment('2026-01-01').subtract(moment.duration(365, 'day')).toDate()); // Wed Jan 01 2025 00:00:00 GMT+0900
Information
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The add/subtract function behaves incorrectly on leap year.
[dayjs 1.11.12]
console.log(dayjs('2023-01-01').add(dayjs.duration(365, 'day')).toDate()); // Mon Jan 01 2024 00:00:00 GMT+0900
console.log(dayjs('2024-01-01').add(dayjs.duration(365, 'day')).toDate()); // Wed Jan 01 2025 00:00:00 GMT+0900 <-- wrong
console.log(dayjs('2025-01-01').add(dayjs.duration(365, 'day')).toDate()); // Thu Jan 01 2026 00:00:00 GMT+0900
console.log(dayjs('2024-01-01').subtract(dayjs.duration(365, 'day')).toDate()); // Sun Jan 01 2023 00:00:00 GMT+0900
console.log(dayjs('2025-01-01').subtract(dayjs.duration(365, 'day')).toDate()); // Mon Jan 01 2024 00:00:00 GMT+0900 <-- wrong
console.log(dayjs('2026-01-01').subtract(dayjs.duration(365, 'day')).toDate()); // Wed Jan 01 2025 00:00:00 GMT+0900
[moment.js]
console.log(moment('2023-01-01').add(moment.duration(365, 'day')).toDate()); // Mon Jan 01 2024 00:00:00 GMT+0900
console.log(moment('2024-01-01').add(moment.duration(365, 'day')).toDate()); // Tue Dec 31 2024 00:00:00 GMT+0900 <-- correct
console.log(moment('2025-01-01').add(moment.duration(365, 'day')).toDate()); // Wed Jan 01 2025 00:00:00 GMT+0900
console.log(moment('2024-01-01').subtract(moment.duration(365, 'day')).toDate()); // Sun Jan 01 2023 00:00:00 GMT+0900
console.log(moment('2025-01-01').subtract(moment.duration(365, 'day')).toDate()); // Tue Jan 02 2024 00:00:00 GMT+0900 <-- correct
console.log(moment('2026-01-01').subtract(moment.duration(365, 'day')).toDate()); // Wed Jan 01 2025 00:00:00 GMT+0900
Information
The text was updated successfully, but these errors were encountered: