FIX: Resolve issues with Next Monday for bookmarks not working in certain locales (#9737)

In moment.js the .day() function can accept a day string but this is locale based, so e.g. in Finnish locale the string "Monday" means nothing and will parse incorrectly to Sunday. To resolve this we always use the moment.js number for the day of the week we want.
This commit is contained in:
Martin Brennan 2020-05-11 13:59:14 +10:00 committed by GitHub
parent bb4e8899c4
commit 29842e682b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -23,6 +23,8 @@ const GLOBAL_SHORTCUTS_TO_PAUSE = ["c", "r", "l", "d", "t"];
const START_OF_DAY_HOUR = 8;
const LATER_TODAY_CUTOFF_HOUR = 17;
const LATER_TODAY_MAX_HOUR = 18;
const MOMENT_MONDAY = 1;
const MOMENT_THURSDAY = 4;
const BOOKMARK_BINDINGS = {
enter: { handler: "saveAndClose" },
@ -220,7 +222,7 @@ export default Controller.extend(ModalFunctionality, {
@discourseComputed()
showLaterThisWeek() {
return this.now().day() < 4; // 4 is Thursday
return this.now().day() < MOMENT_THURSDAY;
},
@discourseComputed("parsedLastCustomReminderDatetime")
@ -238,7 +240,7 @@ export default Controller.extend(ModalFunctionality, {
@discourseComputed()
startNextBusinessWeekFormatted() {
return this.nextWeek()
.day("Monday")
.day(MOMENT_MONDAY)
.format(I18n.t("dates.long_no_year"));
},
@ -374,7 +376,7 @@ export default Controller.extend(ModalFunctionality, {
case REMINDER_TYPES.NEXT_WEEK:
return this.nextWeek();
case REMINDER_TYPES.START_OF_NEXT_BUSINESS_WEEK:
return this.nextWeek().day("Monday");
return this.nextWeek().day(MOMENT_MONDAY);
case REMINDER_TYPES.LATER_THIS_WEEK:
return this.laterThisWeek();
case REMINDER_TYPES.NEXT_MONTH: