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(VDatePicker): show correct week number for selected locale #20794

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

simon-tackstrand
Copy link

Description

Current getWeek implementation does not work for different locales.
Uses @date-io adapter to calculate week number.

resolves #20490, #20724

Requires @date-io version >= 3.2.0 for any project referencing vuetify

The previous getWeek implementation has been moved to the VuetifyDateAdapter, meaning the bug will still exist for those not using any @date-io implementation.

Markup:

<template>
  <v-app>
    <v-container>
      <v-row>
        <v-col cols="12">
          <div style="height: 600px">
            <v-locale-provider locale="sv">
              <v-date-picker show-week />
            </v-locale-provider>
          </div>
        </v-col>
      </v-row>
    </v-container>
  </v-app>
</template>

<script>
  export default {
    name: 'Playground',
    setup () {
      return {
        //
      }
    },
  }
</script>

@johnleider
Copy link
Member

Are you saying the only way to resolve this is to require a dependency?

@simon-tackstrand
Copy link
Author

simon-tackstrand commented Jan 28, 2025

Are you saying the only way to resolve this is to require a dependency?

The dependency '@date-io' is already included in vuetify 3 so it is already required. With this PR we have just updated to a version which has a method for "getWeek". This enables anyone to get a correct getWeek implementation for all locales using any @date-io adapter compared to currently where a vuetify specific method is always used, even when a @date-io adapter is provided.

The VuetifyDateAdapter will still work for 'en-US', but this PR does NOT resolve the issue for locales where it calculates the week incorrectly. I will leave it for you to decide on how to proceed going forward with updating the VuetifyDateAdapter, in my point of view it is rather complex to get it correct for all locales since it requires information about each locale. An easier alternative could be a vuetify 2 inspired approach where the API allows the user to specify locale-first-day-of-year.

The approach in this PR will allow anyone using a @date-io adapter to get a correct locale specific getWeek implementation. For those choosing to use the VuetifyDateAdapter the functionality will remain unchanged.

I would suggest to include this in the next release of Vuetify to give an option for those having issues and being without any alternative other than to disable 'show-week'. The issues with the VuetifyDateAdapter can then be addressed later.

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.

[Bug Report][3.6.7] Wrong calculation of the calendar week in date composable
3 participants