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(date-picker): refactor date utility functions and week picker to correctly show selected week #2970

Merged
merged 3 commits into from
Feb 21, 2024

Conversation

Summer-Shen
Copy link
Contributor

@Summer-Shen Summer-Shen commented Feb 10, 2024

Types of changes

  • New feature
  • Bug fix
  • Enhancement
  • Component style change
  • Typescript definition change
  • Documentation change
  • Coding style change
  • Refactoring
  • Test cases
  • Continuous integration
  • Breaking change
  • Others

Background and context

#2896

Solution

Locale methods in Dayjs sometimes does not change the way dates respond to weekStart customizations. Therefore we rewrite the methods

  • startOfWeek that returns the start day of week and
  • isSameWeek that compares the week numbers of two dates,

calculating week numbers that changes with weekStart.

Dayjs 中的 locale 方法有时不会改变日期对自定义 weekStart 的响应方式。因此,重写了

  • 返回一周开始日期的 startOfWeek 方法和
  • 比较两个日期的周数的 isSameWeek 方法

以计算随 weekStart 变化的周数。

How is the change tested?

  • Please see the updated WeekPicker demos and switch locale to English to see the correct behavior.
  • 请查看更新后的 WeekPicker demo,并将语言切换为英语,以查看正确的行为。

Changelog

Component Changelog(CN) Changelog(EN) Related issues Type
date-picker fix(date-picker):重构日期 utility 函数和 WeekPicker,以正确显示所选星期 fix(date-picker): refactor date utility functions and week picker to correctly show selected week Close #2896 Bug fix
date-picker docs(date-picker):更新 demo 中 WeekPicker 与 dayStartOfWeek 的用法 docs(date-picker): update WeekPicker usage with dayStartOfWeek in demo Documentation change

Checklist:

  • Test suite passes (npm run test)
  • Provide changelog for relevant changes (e.g. bug fixes and new features) if applicable.
  • Changes are submitted to the appropriate branch (e.g. features should be submitted to feature branch and others
    should be submitted to main branch)

Other information

Copy link

codesandbox bot commented Feb 10, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@flsion flsion self-assigned this Feb 21, 2024
@flsion flsion added the type: 🐞 bug Something isn't working label Feb 21, 2024
@flsion flsion added this to the 2.54.5 milestone Feb 21, 2024
@flsion flsion merged commit 22755e1 into arco-design:main Feb 21, 2024
2 of 4 checks passed
@Summer-Shen Summer-Shen deleted the fix/week-picker-with-week-start branch March 26, 2024 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: 🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

date-picker为周的时候显示的多语言和开始时间结束时间有误
2 participants