Umbraco-CMS
Umbraco-CMS copied to clipboard
First day of week should be Monday for en-UK in datetime picker
Which exact Umbraco version are you using? For example: 9.0.1 - don't just write v9
9.5.0
Bug summary
If I select that a user has "English UK" as "language" in the backend, the first day of the week as displayed in the picker should be Monday, but it is now showing as Sunday.
Specifics
.NET correctly returns Monday as the first day of the week for en-UK https://dotnetfiddle.net/htXT6g
Steps to reproduce
Set a user to
Go to a doctype with a date:
Expected result / actual result
It should show Monday (as it happens if I set it to Italian or French)
Hi there @simonech!
Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.
We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.
- We'll assess whether this issue relates to something that has already been fixed in a later version of the release that it has been raised for.
- If it's a bug, is it related to a release that we are actively supporting or is it related to a release that's in the end-of-life or security-only phase?
- We'll replicate the issue to ensure that the problem is as described.
- We'll decide whether the behavior is an issue or if the behavior is intended.
We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.
Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:
any news on this ticket?
Hi @simonech,
We're writing to let you know that we would love some help with this issue. We feel that this issue is ideal to flag for a community member to work on it. Once flagged here, folk looking for issues to work on will know to look at yours. Of course, please feel free work on this yourself ;-). If there are any changes to this status, we'll be sure to let you know.
For more information about issues and states, have a look at this blog post.
Thanks muchly, from your friendly Umbraco GitHub bot :-)
Seems like a bug! We'd love a little help with that please.
It shouldn't require too much to fix this #famouslastwords
I can try having a look 😉
I did some investigations and I think Umbraco is not doing anything. Might even be a bug in the date-picker package
I think Umbraco still uses the Pikaday package for the date picker. If so, it has an option for setting the first day of the week (via the firstDay
option):
https://github.com/Pikaday/Pikaday#configuration
Umbraco also ships with moment.js, so it seems we can determine the start of the week via moment().startOf('week').day()
. But I need to test that to be sure.
I'm not sure there is a "global" fix for this, so this likely needs to be fixed in each controller or directive that uses Pikaday. Is your screenshot of the date picker data type?
It is using flatpickr now. Yeah, that screenshot was the date picker data type.
The issue is that flatpikr doesn't differentiate between en-US and en-UK.
The default config in the l10n folder always uses 0
as start day.
While in Italian it uses 1
.
There seem to be some localisation customisation possible, https://flatpickr.js.org/localization/ , but not sure it is that trivial to fix in Umbraco.
In the umbraco datepicker directive, the code removes the second part of the locale, so obviously there is no difference between en-us
and en-uk
userLocale = user.locale;
if (userLocale.indexOf('-') > -1) {
userLocale = userLocale.split('-')[0];
}
https://github.com/umbraco/Umbraco-CMS/blob/78786e942fa302b011ed9e4782a28d1f32f6f585/src/Umbraco.Web.UI.Client/src/common/directives/components/umbdatetimepicker.directive.js#L107
A fix could be to check if the user.locale is en-uk and add
locale: {
firstDayOfWeek: 1
}
to the initialisation.
Great. Seems Flatpickr only supports language, but not country:
https://github.com/flatpickr/flatpickr/tree/master/src/l10n
I wonder if we can set the locale, but then also the first day of the week 🤔
I've also created a ticket on the flatpickr repo: https://github.com/flatpickr/flatpickr/issues/2798
I think with the workaround I put in previous comment, the en-uk could be fixed, but not as a general solution
The last example here may be relevant:
https://github.com/flatpickr/flatpickr/issues/2327#issuecomment-730144138
Although here Finish
is probably the entire locale object, and not the string as we have. But might still work.
I know I'm an edge case here, but I have a number of Umbraco installations for religious institutions where Sunday is the preferred first day of the week (it's also my personal preference).
If this is "fixed", then the ability to choose what day of the week a calendar starts on would be helpful.
I also think there's a bit of a category error here in the profile page:
If I select that a user has "English UK" as "language"
We're asking the user to choose a language, but that also sets the culture. Language != culture. Especially when we're talking about such a widely used language as English.