mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
GrafanaData: Fix week start for non-English browsers (#50582)
* grafana-data: Fix start week for non-English browsers * apply review suggestion
This commit is contained in:
parent
b184280cb3
commit
99c8ce5ab9
@ -126,10 +126,15 @@ export const getWeekdayIndex = (day: string) => {
|
||||
return moment.weekdays().findIndex((wd) => wd.toLowerCase() === day.toLowerCase());
|
||||
};
|
||||
|
||||
export const getWeekdayIndexByEnglishName = (day: string) =>
|
||||
['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'].findIndex(
|
||||
(wd) => wd.toLowerCase() === day.toLowerCase()
|
||||
);
|
||||
|
||||
export const setWeekStart = (weekStart?: string) => {
|
||||
const suffix = '-weekStart';
|
||||
const language = getLocale().replace(suffix, '');
|
||||
const dow = weekStart ? getWeekdayIndex(weekStart) : -1;
|
||||
const dow = weekStart ? getWeekdayIndexByEnglishName(weekStart) : -1;
|
||||
if (dow !== -1) {
|
||||
moment.locale(language + suffix, {
|
||||
parentLocale: language,
|
||||
|
Loading…
Reference in New Issue
Block a user