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

Wrong weekend highlighting when using german locale #170

Open
1 task done
luguco opened this issue Oct 24, 2024 · 2 comments
Open
1 task done

Wrong weekend highlighting when using german locale #170

luguco opened this issue Oct 24, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@luguco
Copy link

luguco commented Oct 24, 2024

Checklist

  • I've verified that I'm running react-big-schedule latest version.

Describe the bug

When using german locale ('de'), the weekends are incorrectly calculated and highlighted.
That's because in germany the first day of the week is monday, not sunday.

grafik

Reproduction Link/Code

import 'dayjs/locale/de';
dayjs.locale('de')

schedulerData.setSchedulerLocale('de-de');
schedulerData.setCalendarPopoverLocale('de_DE');

Steps to reproduce

  1. Set the locale to german ('de')

Operating System

Windows

Browser

Firefox

React version

18.3.1

react-big-schedule version

4.4.1

Additional Information

Imho, this bug could be rather easy fixed by a slight adjustment of the function isNonWorkingTime in behaviors.js:
Instead of using .weekday(), use .day(), since that is not locale dependent and will always return mondays as 1.

[...]
var dayOfWeek = localeDayjs(new Date(time)).day();
  return dayOfWeek === 0 || dayOfWeek === 6;
@luguco luguco added the bug Something isn't working label Oct 24, 2024
@ansulagrawal
Copy link
Member

I will look into it.

ansulagrawal added a commit that referenced this issue Nov 12, 2024
Fix Locale highlighting issue: #170 

Thanks to @luguco for raising a bug.
@ansulagrawal
Copy link
Member

@luguco thanks for raising a bug. I have fix the issue in version 4.4.4.
You can test it or you can check it out at https://codesandbox.io/p/sandbox/27sv3q

@ansulagrawal ansulagrawal self-assigned this Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants