Skip to content
New issue

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

Duration Big Bug #2666

Open
qinfanheaven opened this issue May 30, 2024 · 1 comment
Open

Duration Big Bug #2666

qinfanheaven opened this issue May 30, 2024 · 1 comment

Comments

@qinfanheaven
Copy link

const endTime = dayjs.unix(1716998400).add(32, 'day'); // 2024/7/1/ 00:00:00
const now = dayjs(); // 2024/5/30 13:50:50

const duration = dayjs.duration(endTime.diff(now));

console.log(duration.hours());
// output is "0" which should be "10"
// when change 32 to 30, the hours func returns 10

@floydkim
Copy link

floydkim commented Jun 4, 2024

dayjs 1.11.11

The problem occurs when the difference become 31 days.

const now = dayjs('2024-05-02T01:00:00');


const future30 = now.add(30, 'day');
const duration30 = dayjs.duration(future30.diff(now));
console.log(duration30.hours()); // 🆗 returns 0
console.log('iso', duration30); // "P30D"


const future31 = now.add(31, 'day');
const duration31 = dayjs.duration(future31.diff(now));
console.log(duration31.hours()); // 💥 returns 14
console.log('iso', duration31); // "P1MT14H"

#1433 (comment)
#2565 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants