FIX: Don't show the Tis Weekend option in date pickers on Sundays

FIX: Don’t show the Tis Weekend option in date pickers on Sundays

diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/future-date-input-selector-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/future-date-input-selector-test.js
index 37212d5..ad368c5 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/future-date-input-selector-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/future-date-input-selector-test.js
@@ -168,6 +168,41 @@ discourseModule(
       },
     });
 
+    componentTest("doesn't show 'This Weekend' on Sundays", {
+      /*
+        We need this test to avoid regressions.
+        We tend to write such conditions and think that
+        they mean the beginning of work week
+        (Monday, Tuesday and Wednesday in this specific case):
+
+         if (date.day <= 3) {
+             ...
+         }
+
+        In fact, Sunday will pass this check too, because
+        in moment.js 0 stands for Sunday.
+      */
+
+      template: hbs`
+        {{future-date-input-selector
+          includeWeekend=true
+        }}
+      `,
+
+      beforeEach() {
+        const timezone = moment.tz.guess();
+        this.clock = fakeTime("2100-04-25 18:00:00", timezone, true); // Sunday
+      },
+
+      async test(assert) {
+        await this.subject.expand();
+        const options = getOptions();
+        const thisWeekend = I18n.t("topic.auto_update_input.this_weekend");
+
+        assert.not(options.includes(thisWeekend));
+      },
+    });
+
     componentTest(
       "shows 'Later This Week' instead of 'Later Today' at the end of the day",
       {
diff --git a/app/assets/javascripts/select-kit/addon/components/future-date-input-selector.js b/app/assets/javascripts/select-kit/addon/components/future-date-input-selector.js
index b163c48..495d87c 100644
--- a/app/assets/javascripts/select-kit/addon/components/future-date-input-selector.js
+++ b/app/assets/javascripts/select-kit/addon/components/future-date-input-selector.js
@@ -46,7 +46,7 @@ export const TIMEFRAMES = [
   buildTimeframe({
     id: "this_weekend",
     format: "ddd, h a",
-    enabled: (opts) => opts.day < 5 && opts.includeWeekend,
+    enabled: (opts) => opts.day > 0 && opts.day < 5 && opts.includeWeekend,
     when: (time, timeOfDay) => time.day(6).hour(timeOfDay).minute(0),
     icon: "bed",
   }),

GitHub sha: f79eb207a6f6a251dc5e6f60b4a3fe1fa00f3b70

This commit appears in #13838 which was approved by tgxworld. It was merged by tgxworld.