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

invalid date: wrong diff calculation for some units #2793

Open
JuliaMV opened this issue Dec 20, 2024 · 0 comments
Open

invalid date: wrong diff calculation for some units #2793

JuliaMV opened this issue Dec 20, 2024 · 0 comments

Comments

@JuliaMV
Copy link

JuliaMV commented Dec 20, 2024

Describe the bug
create a dayjs value from null and compare it with current dayjs value:

const currentDate = dayjs();
const expiresOn = dayjs(null);

Check difference for available units:

const diffDays = expiresOn.diff(currentDate, "days");  // NaN
const diffInWeeks = expiresOn.diff(currentDate, "week"); // NaN
const diffMonths = expiresOn.diff(currentDate, "month"); // 0
const diffInQuaters = expiresOn.diff(currentDate, "quarter");  // 0
const diffInYears = expiresOn.diff(currentDate, "year");  // 0
const diffInHours = expiresOn.diff(currentDate, "hour");  // NaN
const diffInMinutes = expiresOn.diff(currentDate, "minute");  // NaN
const diffInSeconds = expiresOn.diff(currentDate, "second");  // NaN

Expected behavior
return value should be NaN for all units

Information

  • Day.js Version: 1.11,13
  • OS: any
  • Browser: any
  • Time zone: any
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

1 participant