This is an automated email from the ASF dual-hosted git repository.

arivero pushed a commit to branch time_comparison_zeros
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/time_comparison_zeros by this 
push:
     new 8d4a139c84 Time Comparison:
8d4a139c84 is described below

commit 8d4a139c8469210b22ec7708279764732fa30743
Author: Antonio Rivero <[email protected]>
AuthorDate: Mon Aug 19 17:17:15 2024 +0200

    Time Comparison:
    
    - Today date must be set to 00:00 so round doesnt affect calculation of the 
shift
---
 .../superset-ui-core/src/time-comparison/getTimeOffset.ts | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git 
a/superset-frontend/packages/superset-ui-core/src/time-comparison/getTimeOffset.ts
 
b/superset-frontend/packages/superset-ui-core/src/time-comparison/getTimeOffset.ts
index 84047841e4..fbcbb8d5d4 100644
--- 
a/superset-frontend/packages/superset-ui-core/src/time-comparison/getTimeOffset.ts
+++ 
b/superset-frontend/packages/superset-ui-core/src/time-comparison/getTimeOffset.ts
@@ -27,12 +27,12 @@ export const parseDttmToDate = (
   computingShifts = false,
 ) => {
   const now = new Date();
-  if (
-    dttm === 'now' ||
-    dttm === 'today' ||
-    dttm === 'No filter' ||
-    dttm === ''
-  ) {
+  if (dttm === 'now' || dttm === 'No filter' || dttm === '') {
+    return now;
+  }
+
+  if (dttm === 'today') {
+    now.setHours(0, 0, 0, 0);
     return now;
   }
 
@@ -154,6 +154,9 @@ export const computeCustomDateTime = (
   let parsed: Date;
   if (dttm === 'now' || dttm === 'today') {
     parsed = new Date();
+    if (dttm === 'today') {
+      parsed.setHours(0, 0, 0, 0);
+    }
   } else {
     parsed = new Date(dttm);
   }

Reply via email to