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

Is there a way to set the week start date of the date? There is a need for this in the project. Can this function be added? #5877

Closed
1 task
WormGirl opened this issue Aug 8, 2022 · 5 comments

Comments

@WormGirl
Copy link

WormGirl commented Aug 8, 2022

  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

国际化场景,修改日期显示面板的周起始日,如 日一二三四五六

What does the proposed API look like?

firstDayOfWeek 周起始日 Number 1 到 7 7

@github-actions github-actions bot changed the title 有没有办法设置日期的周起始日,项目中有这个需求,是否可以加一下这个功能 Is there a way to set the week start date of the date? There is a need for this in the project. Can this function be added? Aug 8, 2022
@WormGirl
Copy link
Author

WormGirl commented Aug 8, 2022

可以通过dayjs设置

import dayjs from 'dayjs';
import { ILocale } from '@/types';
import { useI18n } from 'vue-i18n';

const { locale, getLocaleMessage } = useI18n();
watch(
  () => locale.value,
  value => {
    const options = getLocaleMessage(value).dayjs as unknown as ILocale;
    // 设置周起始日
    options.weekStart = 6;
    dayjs.locale(options);
  },
  {
    immediate: true
  }
);

@tangjinzhou
Copy link
Member

@github-actions
Copy link

github-actions bot commented Oct 8, 2022

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@Benjamin369
Copy link

可以在多国设置的地方添加如下设置

import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
import updateLocale from 'dayjs/plugin/updateLocale'
dayjs.locale('zh-cn');
// 设置每周的第一天
dayjs.extend(updateLocale)
dayjs.updateLocale('zh-cn', {weekStart: 0})

Copy link

github-actions bot commented Mar 3, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants