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

weekOfYear week method doesn't seems to handle week number 53 for 'fr' locale #956

Closed
4rno opened this issue Jul 9, 2020 · 4 comments
Closed
Labels

Comments

@4rno
Copy link

4rno commented Jul 9, 2020

Describe the bug
I have an issue with the dayjs week() method compared with the moment.js one.
My issue is probably linked to this one #772

Expected behavior
I tried with that date: 2020-12-31, which is supposed to be a day in the week number 53. (if i refer to this http://www.whatweekisit.org/ or any french calendar).

Here is an example of what moment.js week() method return for 'fr' and 'en-gb' locales: https://runkit.com/4rno/5f05ee0eef35c50013368d1b
moment.js returns week 53. Which is correct

But, I have different results with dayjs: https://runkit.com/4rno/5f05ebfc841930001389a53e
In 'fr' locale, it returns week number 1. But in 'en-gb' locale, it returns correctly week 53.

It seems to be linked with the parameter yearStart in locale config files. But i don't know exactly how it is supposed to work.
Or maybe i'm wrong somewhere.

Information

  • Day.js Version v1.8.29
  • OS: [Mac OS]
  • Browser [Chrome 83]
  • Time zone: [CET]
@iamkun iamkun closed this as completed in 14ab808 Jul 10, 2020
@iamkun
Copy link
Owner

iamkun commented Jul 10, 2020

Thanks, Update French (fr) locale to set correct yearStart config.

iamkun pushed a commit that referenced this issue Jul 22, 2020
## [1.8.30](v1.8.29...v1.8.30) (2020-07-22)

### Bug Fixes

* Add Haitian Creole (ht) and Spanish Puerto Rico (es-pr) locale configs ([#958](#958)) ([b2642e2](b2642e2))
* Fix UTC plugin wrong hour bug while adding month or year  ([#957](#957)) ([28ae070](28ae070))
* Update French (fr) locale to set correct yearStart ([14ab808](14ab808)), closes [#956](#956)
@iamkun
Copy link
Owner

iamkun commented Jul 22, 2020

🎉 This issue has been resolved in version 1.8.30 🎉

The release is available on:

Your semantic-release bot 📦🚀

@flomoto
Copy link

flomoto commented Mar 24, 2021

Same problem in german locale. 4 january needs to be week 1, not 2.

@niklasHagner
Copy link

niklasHagner commented Sep 19, 2021

Just wanted to let you know I was having this issue too while using dayjs version 1.10.4 but after upgrading to 10.10.7 it's resolved. ✅

So the latest version as of today works as expected.
But thought I'd write here anyway cause this thread suggest it was fixed as early as version 1.8.30 , and that wasn't the case for me. At least not with my setup of multiple plugins

The code I was using

var dayjs = require('dayjs')
var isToday = require('dayjs/plugin/isToday')
var weekOfYear = require('dayjs/plugin/weekOfYear')
var utc = require('dayjs/plugin/utc') 
var timezone = require('dayjs/plugin/timezone')
const { months } = require('dayjs/locale/sv')
dayjs.extend(isToday)
dayjs.extend(weekOfYear)
dayjs.extend(utc)
dayjs.extend(timezone)
dayjs.tz.setDefault("Sweden/Stockholm")
require('dayjs/locale/sv')
dayjs.locale('sv')

//Test scenario
var firstDayOf2021 = dayjs("2021-01-01");
console.log("weekNumber:", firstDayOf2021.week()); //With version version 1.10.4 it'll incorrectly output week1, with 1.10.7 it'll correctly output week53

andrewhood125ruhuc added a commit to andrewhood125ruhuc/SidRH2 that referenced this issue May 10, 2022
## [1.8.30](iamkun/dayjs@v1.8.29...v1.8.30) (2020-07-22)

### Bug Fixes

* Add Haitian Creole (ht) and Spanish Puerto Rico (es-pr) locale configs ([#958](iamkun/dayjs#958)) ([b2642e2](iamkun/dayjs@b2642e2))
* Fix UTC plugin wrong hour bug while adding month or year  ([#957](iamkun/dayjs#957)) ([28ae070](iamkun/dayjs@28ae070))
* Update French (fr) locale to set correct yearStart ([14ab808](iamkun/dayjs@14ab808)), closes [#956](iamkun/dayjs#956)
andrewhood125ruhuc added a commit to andrewhood125ruhuc/SidRH2 that referenced this issue May 10, 2022
## [1.8.30](iamkun/dayjs@v1.8.29...v1.8.30) (2020-07-22)

### Bug Fixes

* Add Haitian Creole (ht) and Spanish Puerto Rico (es-pr) locale configs ([#958](iamkun/dayjs#958)) ([b2642e2](iamkun/dayjs@b2642e2))
* Fix UTC plugin wrong hour bug while adding month or year  ([#957](iamkun/dayjs#957)) ([28ae070](iamkun/dayjs@28ae070))
* Update French (fr) locale to set correct yearStart ([14ab808](iamkun/dayjs@14ab808)), closes [#956](iamkun/dayjs#956)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants