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

fix(intervals): sort ASC #3628

Merged

Conversation

imwh0im
Copy link
Contributor

@imwh0im imwh0im commented Dec 21, 2023

@imwh0im
Copy link
Contributor Author

imwh0im commented Dec 21, 2023

const a = +new Date('1970-01-01T02:00:00.000Z');
const b = +new Date('1970-01-01T03:00:00.000Z');
const c = +new Date('1969-12-31T23:30:00.000Z');
const d = +new Date('1970-01-01T02:30:00.000Z');

console.log(a, b, c, d);
console.log([a, b].sort(), [c, d].sort())
console.log(
  [a, b].sort((a, b) => a - b),
  [c, d].sort((a, b) => a - b),
);
> 7200000 10800000 -1800000 9000000
> Array [10800000, 7200000] Array [-1800000, 9000000]
> Array [7200000, 10800000] Array [-1800000, 9000000

Copy link
Member

@kossnocorp kossnocorp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you a lot!

@kossnocorp kossnocorp merged commit 9ac551c into date-fns:main Dec 22, 2023
6 checks passed
@kossnocorp
Copy link
Member

Shipped with date-fns@3.0.6

@imwh0im imwh0im deleted the fix/are-intervals-over-lappings-sort branch December 24, 2023 13:05
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

Successfully merging this pull request may close these issues.

None yet

2 participants