Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use first day of week setting from server #6134

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}
Loading