Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
date-fns isSameWeek not working as expected

I'm new with date-fns but intuitively, I would expect this to be true:

isSameWeek(new Date(2021, 11, 11), new Date(2021, 11, 12))

But it actually is false

I must be missing something?

It looks like Thursday seems to be the start of the week because this is true:

isSameWeek(new Date(2021, 11, 12), new Date(2021, 11, 18))

EDIT: When I do this

isSameWeek(new Date(2021, 11, 11), new Date(2021, 11, 12), {weekStartsOn: 1})

It now is true... I'm confused.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The months start at 0 being January.

So 11 is December.

December 11 is a Saturday, the 12th is Sunday (start of the next week). So they are not in the same week.

December 12 is Sunday, December 18th is the Saturday of the same week. So they are in the same week.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!