react-scheduler / react-big-schedule

React Big Schedule is a powerful and intuitive scheduler and resource planning solution built with React.
https://react-big-schedule.vercel.app/
MIT License
101 stars 23 forks source link

Wrong weekend highlighting when using german locale #170

Open luguco opened 1 month ago

luguco commented 1 month ago

Checklist

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;
ansulagrawal commented 1 month ago

I will look into it.

ansulagrawal commented 2 weeks ago

@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