Skip to content

Commit

Permalink
Merge pull request #6135 from nextcloud/backport/6134/stable4.7
Browse files Browse the repository at this point in the history
[stable4.7] fix: use first day of week setting from server
  • Loading branch information
miaulalala authored Jul 11, 2024
2 parents 8b73ecd + f7628d0 commit 39dc9dc
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 @@ -19,10 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
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 @@ -32,7 +29,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 @@ -24,6 +24,7 @@ import {
getDayNames,
getDayNamesMin,
getDayNamesShort,
getFirstDay,
getMonthNames,
getMonthNamesShort,
} from '@nextcloud/l10n'
Expand All @@ -48,7 +49,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 @@ -23,7 +23,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import { getLanguage, getLocale } from '@nextcloud/l10n'
import { getFirstDay, getLanguage, getLocale } from '@nextcloud/l10n'
import moment from '@nextcloud/moment'

/**
Expand Down Expand Up @@ -59,7 +59,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 @@ -98,12 +98,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 39dc9dc

Please sign in to comment.