Skip to content

Commit

Permalink
Merge pull request #6134 from nextcloud/fix/use-first-day-from-server
Browse files Browse the repository at this point in the history
fix: use first day of week setting from server
  • Loading branch information
st3iny authored Jul 10, 2024
2 parents 4485575 + 3203378 commit ea0e759
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
7 changes: 2 additions & 5 deletions src/fullcalendar/localization/localeProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { translate as t, getLanguage } from '@nextcloud/l10n'
import {
getFirstDayOfWeekFromMomentLocale,
} from '../../utils/moment.js'
import { translate as t, getLanguage, getFirstDay } from '@nextcloud/l10n'

/**
* Returns localization settings for the FullCalender package.
Expand All @@ -15,7 +12,7 @@ import {
*/
const getFullCalendarLocale = () => {
return {
firstDay: getFirstDayOfWeekFromMomentLocale(),
firstDay: getFirstDay(),
locale: getLanguage(),
// TRANSLATORS W is an abbreviation for Week
weekText: t('calendar', 'W'),
Expand Down
3 changes: 2 additions & 1 deletion src/utils/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getDayNames,
getDayNamesMin,
getDayNamesShort,
getFirstDay,
getMonthNames,
getMonthNamesShort,
} from '@nextcloud/l10n'
Expand All @@ -31,7 +32,7 @@ const getLangConfigForVue2DatePicker = (momentLocale) => {
weekdays: getDayNames(),
weekdaysShort: getDayNamesShort(),
weekdaysMin: getDayNamesMin(),
firstDayOfWeek: moment.localeData(momentLocale).firstDayOfWeek(),
firstDayOfWeek: getFirstDay(),
firstWeekContainsDate: moment.localeData(momentLocale).firstDayOfYear(),
meridiem: moment.localeData(momentLocale).meridiem,
meridiemParse: moment.localeData(momentLocale).meridiemParse,
Expand Down
13 changes: 2 additions & 11 deletions src/utils/moment.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { getLanguage, getLocale } from '@nextcloud/l10n'
import { getFirstDay, getLanguage, getLocale } from '@nextcloud/l10n'
import moment from '@nextcloud/moment'

/**
Expand Down Expand Up @@ -38,7 +38,7 @@ export default async function loadMomentLocalization() {
llll: moment.localeData(realLocale).longDateFormat('llll'),
},
week: {
dow: moment.localeData(realLocale).firstDayOfWeek(),
dow: getFirstDay(),
doy: moment.localeData(realLocale).firstDayOfYear(),
},
})
Expand Down Expand Up @@ -77,12 +77,3 @@ async function getLocaleFor(locale) {

return 'en'
}

/**
* Get's the first day of a week based on a moment locale
*
* @return {number}
*/
export function getFirstDayOfWeekFromMomentLocale() {
return moment.localeData().firstDayOfWeek()
}

0 comments on commit ea0e759

Please sign in to comment.