From ccbd499bdf8ca7fda3027c2a6389816358e766a4 Mon Sep 17 00:00:00 2001 From: Hussein Awala Date: Thu, 17 Aug 2023 23:43:45 +0200 Subject: [PATCH] Fix a bug in formatDuration method --- airflow/www/static/js/cluster-activity/nav/FilterBar.tsx | 2 +- airflow/www/static/js/datetime_utils.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/airflow/www/static/js/cluster-activity/nav/FilterBar.tsx b/airflow/www/static/js/cluster-activity/nav/FilterBar.tsx index 6cae7854f184..b4f840cb5fc6 100644 --- a/airflow/www/static/js/cluster-activity/nav/FilterBar.tsx +++ b/airflow/www/static/js/cluster-activity/nav/FilterBar.tsx @@ -81,7 +81,7 @@ const FilterBar = () => { - over the last{" "} + for a period of{" "} {formatDuration(getDuration(formattedStartDate, formattedEndDate))} diff --git a/airflow/www/static/js/datetime_utils.js b/airflow/www/static/js/datetime_utils.js index c23f8d665e83..5eb1f1defb8f 100644 --- a/airflow/www/static/js/datetime_utils.js +++ b/airflow/www/static/js/datetime_utils.js @@ -120,7 +120,8 @@ export const getDuration = (startDate, endDate) => export const formatDuration = (dur) => { const duration = moment.duration(dur); - const days = duration.days(); + const totalDays = duration.asDays(); + const days = Math.floor(totalDays); // .as('milliseconds') is necessary for .format() to work correctly return `${days > 0 ? `${days}d` : ""}${moment .utc(duration.as("milliseconds"))