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

[Bug Report][3.6.7] Wrong calculation of the calendar week in date composable #20490

Open
ChristianMaehler opened this issue Sep 18, 2024 · 0 comments

Comments

@ChristianMaehler
Copy link

Environment

Vuetify Version: 3.6.7
Vue Version: 3.4.23
Browsers: Chrome 128.0.0.0
OS: Mac OS 10.15.7

Steps to reproduce

use a v-date-picker, display calendar week and navigate to December 2024

Expected Behavior

The week starting the 30th of December should be week 1 not week 53

Actual Behavior

Week 53 is dispayed instead of week 1

Reproduction Link

https://play.vuetifyjs.com/#...

Other comments

I guess it's a bug in the getWeek function in https://github.com/vuetifyjs/vuetify/blob/master/packages/vuetify/src/composables/date/date.ts

I tried this function also and it returns 53.

According to the ISO standard it should be week 1: https://en.wikipedia.org/wiki/ISO_week_date

"...
First week
The ISO 8601 definition for week 01 is the week with the first Thursday of the Gregorian year (i.e. of January) in it. The following definitions based on properties of this week are mutually equivalent, since the ISO week starts with Monday:

It is the first week with a majority (4 or more) of its days in January.
Its first day is the Monday nearest to 1 January.
It has 4 January in it. Hence the earliest possible first week extends from Monday 29 December (previous Gregorian year) to Sunday 4 January, the latest possible first week extends from Monday 4 January to Sunday 10 January.
It has the year's first working day in it, if Saturdays, Sundays and 1 January are not working days.
..."

Also performed a Wolfram Alpha search: https://www.wolframalpha.com/input?input=what+is+the+date+of+the+first+week+of+2025

There is a working implementation here: https://gist.github.com/vincentorback/8edffeca20e7a9e5e2a6?permalink_comment_id=1769808 and some more info here https://stackoverflow.com/questions/58708417/why-is-1-added but I don't know whether you can use this code (licence?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant