This is an automated email from the ASF dual-hosted git repository. bbovenzi pushed a commit to branch consistent-duration-format in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 3638b4fbada9750c78f514bbca2e269cd10604a4 Author: Brent Bovenzi <[email protected]> AuthorDate: Wed Apr 13 14:27:21 2022 -0400 Make duration formats more consistent Use the same formatting function, `convertSecsToHumanReadable()`, in Grid view as we have for other js files. --- airflow/www/static/js/datetime_utils.js | 8 +++----- airflow/www/static/js/tree/dagRuns/index.jsx | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/airflow/www/static/js/datetime_utils.js b/airflow/www/static/js/datetime_utils.js index 1cbd6fa2d9..729bb89e15 100644 --- a/airflow/www/static/js/datetime_utils.js +++ b/airflow/www/static/js/datetime_utils.js @@ -17,7 +17,7 @@ * under the License. */ -/* global moment, $, document */ +/* global moment, $, document, convertSecsToHumanReadable */ export const defaultFormat = 'YYYY-MM-DD, HH:mm:ss'; export const defaultFormatWithTZ = 'YYYY-MM-DD, HH:mm:ss z'; export const defaultTZFormat = 'z (Z)'; @@ -106,10 +106,8 @@ export const getDuration = (startDate, endDate) => ( ); export const formatDuration = (dur) => { - const duration = moment.duration(dur); - const days = duration.days(); - // .as('milliseconds') is necessary for .format() to work correctly - return `${days > 0 ? `${days}d` : ''}${moment.utc(duration.as('milliseconds')).format('HH:mm:ss')}`; + const duration = moment.duration(dur).as('seconds'); + return convertSecsToHumanReadable(duration); }; export const approxTimeFromNow = (dur) => { diff --git a/airflow/www/static/js/tree/dagRuns/index.jsx b/airflow/www/static/js/tree/dagRuns/index.jsx index ed3918db8a..f4874563ad 100644 --- a/airflow/www/static/js/tree/dagRuns/index.jsx +++ b/airflow/www/static/js/tree/dagRuns/index.jsx @@ -80,7 +80,7 @@ const DagRuns = ({ tableWidth }) => { {formatDuration(max / 2)} </DurationTick> <DurationTick bottom={0}> - 00:00:00 + 0Sec </DurationTick> </> )}
