wired-elements icon indicating copy to clipboard operation
wired-elements copied to clipboard

Fix (calendar): Fixes display error due to locale first-weekday not Sunday #156

Open elingerojo opened this issue 2 years ago • 0 comments

Issue #156

Day number and day names were out of phase when locale first-day-of-the-week was not Sunday. The problem is that the original code assumed Sunday as the first day of the week always.

What has changed:

  1. Accept locale region like: en-GB and de-DE. Previously only the language part was relevant, region was ignored.
  2. Compute first weekday of the week depending on region.
  3. Offset weekday names header and day number to keep phased by columns.

What reviewer should know:

The future and easy way to get the locale first weekday is using Intl.locale.weekInfo.firstDay but is not supported by all major browsers yet, to date. So that, it was obtained by a RegEx string to isolate the locale region and with a extensive region to first weekday map. Understand that this is a hardcoded solution that will cause maintenance debt. To overcome this, both solutions were programmed but the code of the Intl.locale.weekInfo one was commented out for future use.

elingerojo avatar Feb 12 '23 03:02 elingerojo