question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

expect(dayjs('2019-07-28').week()).toBe(30)

See original GitHub issue

Describe the bug Since the introduction of locale.weekStart I expect it to work with e.g .week() plugin, but currently it doesn’t. 2019-07-28 is Sunday, so in en-gb locale it should be part of week 30, not week 31.

In Jest syntax:

require('dayjs/locale/en-gb')
dayjs.locale('en-gb')

expect(dayjs('2019-07-28').week()).toBe(30)

throws:

Expected: 30
Received: 31

Information

  • Day.js Version: 1.8.15
  • OS: MacOS
  • Browser Chrome 76
  • Time zone: Stockholm

UPD: attaching a screenshot of my WeekNumberAware calendar:

image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
g1eny0ungcommented, Aug 8, 2019

I will be working on this. Thanks for finding this problem.

1reaction
kirillgroshkovcommented, Aug 13, 2019

Also, for proper testing - loop over few years of days and compare momentjs and dayjs. There are edge cases around year start that I didn’t manage to fix.

Example of how I tested it: https://github.com/NaturalCycles/time-lib/blob/master/src/plugin/weekOfYear.test.ts

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add
Returns a cloned Day.js object with a specified amount of time added. ... When decimal values are passed for days and weeks, they...
Read more >
Time from now
Range Key Sample Output 0 to 44 seconds s a few seconds ago 45 to 89 seconds m a minute ago 90 seconds to 44 minutes...
Read more >
Format
List of all available formats ; d, 0-6, The day of the week, with Sunday as 0 ; dd, Su-Sa, The min name...
Read more >
Start of Time
Returns a cloned Day.js object and set it to the start of a unit of time. dayjs().startOf('year'). Units are case insensitive, and support...
Read more >
Subtract
Returns a cloned Day.js object with a specified amount of time subtracted. ... When decimal values are passed for days and weeks, they...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found