From 2b2f46670c9843c1b27897e769c400378e0eaf1b Mon Sep 17 00:00:00 2001
From: Gustavo Saiani <gustavo@poe.ma>
Date: Thu, 21 Jul 2022 15:33:56 +0200
Subject: [PATCH] Obey `start_of_week` day setting in filter label (#24161)

---
 frontend/src/metabase/lib/query_time.js                  | 2 +-
 .../filters/pickers/DatePicker/SpecificDatePicker.tsx    | 9 +++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/frontend/src/metabase/lib/query_time.js b/frontend/src/metabase/lib/query_time.js
index 4988377d079..e6e18d2e830 100644
--- a/frontend/src/metabase/lib/query_time.js
+++ b/frontend/src/metabase/lib/query_time.js
@@ -1,5 +1,5 @@
 import _ from "underscore";
-import moment from "moment";
+import moment from "moment-timezone";
 import { assoc } from "icepick";
 import inflection from "inflection";
 import { t, ngettext, msgid } from "ttag";
diff --git a/frontend/src/metabase/query_builder/components/filters/pickers/DatePicker/SpecificDatePicker.tsx b/frontend/src/metabase/query_builder/components/filters/pickers/DatePicker/SpecificDatePicker.tsx
index bdf582e9a91..c608dd106c7 100644
--- a/frontend/src/metabase/query_builder/components/filters/pickers/DatePicker/SpecificDatePicker.tsx
+++ b/frontend/src/metabase/query_builder/components/filters/pickers/DatePicker/SpecificDatePicker.tsx
@@ -10,6 +10,7 @@ import ExpandingContent from "metabase/components/ExpandingContent";
 import HoursMinutesInput from "./HoursMinutesInput";
 
 import moment from "moment";
+import momentTimezone from "moment-timezone";
 import { getTimeComponent, setTimeComponent } from "metabase/lib/query_time";
 
 type Props = {
@@ -27,7 +28,7 @@ type Props = {
 
 const SpecificDatePicker: React.FC<Props> = props => {
   const onChange = (
-    date?: string | moment.Moment,
+    date?: string | momentTimezone.Moment,
     hours?: number | null,
     minutes?: number | null,
   ) => {
@@ -66,7 +67,7 @@ const SpecificDatePicker: React.FC<Props> = props => {
           onBlurChange={({ target: { value } }: any) => {
             const date = moment(value, dateFormat);
             if (date.isValid()) {
-              onChange(date, hours, minutes);
+              onChange(date as momentTimezone.Moment, hours, minutes);
             } else {
               onChange();
             }
@@ -100,8 +101,8 @@ const SpecificDatePicker: React.FC<Props> = props => {
       {calendar && (
         <ExpandingContent isOpen={showCalendar}>
           <Calendar
-            selected={date}
-            initial={date || moment()}
+            selected={date as moment.Moment}
+            initial={(date as moment.Moment) || moment()}
             onChange={value => onChange(value, hours, minutes)}
             isRangePicker={false}
             selectAll={selectAll}
-- 
GitLab