diff --git a/packages/oss-console/src/common/formatters.ts b/packages/oss-console/src/common/formatters.ts index ac8957535..038b07f39 100644 --- a/packages/oss-console/src/common/formatters.ts +++ b/packages/oss-console/src/common/formatters.ts @@ -8,18 +8,6 @@ import { durationToMilliseconds, isValidDate } from './utils'; const defaultUTCFormat = 'l LTS'; -/** Formats a date into a standard string with a moment-style "from now" hint - * ex. 12/21/2017 8:19:36 PM (18 days ago) - */ -export function dateWithFromNow(input: Date) { - if (!isValidDate(input)) { - return unknownValueString; - } - - const date = moment.utc(input); - return `${date.format(defaultUTCFormat)} UTC (${date.fromNow()})`; -} - /** Formats a date into a moment-style "from now" value */ export function dateFromNow(input: Date) { if (!isValidDate(input)) { @@ -51,7 +39,7 @@ export function formatDateUTC(input: Date, formatString?: string) { /** * Gets human-readable date relative to "now" */ -export function formateDateRelative(input: Date, threshold = 24 * 60 * 60 * 1000) { +export function formatDateRelative(input: Date, threshold = 24 * 60 * 60 * 1000) { if (!isValidDate(input)) { return unknownValueString; } @@ -72,6 +60,18 @@ export function formatDateLocalTimezone(input: Date) { return isValidDate(input) ? moment(input).tz(timezone).format('l LTS z') : unknownValueString; } +/** Formats a date into a standard string with a moment-style "from now" hint + * ex. 12/21/2017 8:19:36 PM (18 days ago) + */ +export function dateWithFromNow(input: Date) { + if (!isValidDate(input)) { + return unknownValueString; + } + + const date = moment.utc(input); + return `${formatDateLocalTimezone(input)} (${date.fromNow()})`; +} + /** Outputs a value in milliseconds in (H M S) format (ex. 2h 3m 30s) */ export function millisecondsToHMS(valueMS: number): string { if (valueMS < 0) { diff --git a/packages/oss-console/src/components/Executions/ExecutionDetails/ExecutionMetadata.tsx b/packages/oss-console/src/components/Executions/ExecutionDetails/ExecutionMetadata.tsx index fef119a0c..f5964c717 100644 --- a/packages/oss-console/src/components/Executions/ExecutionDetails/ExecutionMetadata.tsx +++ b/packages/oss-console/src/components/Executions/ExecutionDetails/ExecutionMetadata.tsx @@ -6,7 +6,7 @@ import { Link as RouterLink } from 'react-router-dom'; import styled from '@mui/system/styled'; import * as CommonStylesConstants from '@clients/theme/CommonStyles/constants'; import { dashedValueString } from '@clients/common/constants'; -import { formatDateUTC, protobufDurationToHMS } from '../../../common/formatters'; +import { formatDateLocalTimezone, protobufDurationToHMS } from '../../../common/formatters'; import { timestampToDate } from '../../../common/utils'; import { useCommonStyles } from '../../common/styles'; import { Routes } from '../../../routes/routes'; @@ -85,7 +85,7 @@ export const ExecutionMetadata: React.FC<{}> = () => { }, { label: ExecutionMetadataLabels.time, - value: startedAt ? formatDateUTC(timestampToDate(startedAt)) : dashedValueString, + value: startedAt ? formatDateLocalTimezone(timestampToDate(startedAt)) : dashedValueString, }, { label: ExecutionMetadataLabels.duration, diff --git a/packages/oss-console/src/components/Executions/ExecutionDetails/utils.ts b/packages/oss-console/src/components/Executions/ExecutionDetails/utils.ts index 77e4675a1..28f911bdf 100644 --- a/packages/oss-console/src/components/Executions/ExecutionDetails/utils.ts +++ b/packages/oss-console/src/components/Executions/ExecutionDetails/utils.ts @@ -1,7 +1,7 @@ import { ResourceType } from '../../../models/Common/types'; import { Execution, NodeExecution, TaskExecution } from '../../../models/Execution/types'; import { timestampToDate } from '../../../common/utils'; -import { formatDateUTC } from '../../../common/formatters'; +import { formatDateLocalTimezone } from '../../../common/formatters'; export function isSingleTaskExecution(execution: Execution) { return execution.spec.launchPlan.resourceType === ResourceType.TASK; @@ -21,8 +21,9 @@ export function getTaskExecutionDetailReasons( reasons = reasons.concat( finalReasons.map( (reason) => - (reason.occurredAt ? `${formatDateUTC(timestampToDate(reason.occurredAt))} ` : '') + - reason.message, + (reason.occurredAt + ? `${formatDateLocalTimezone(timestampToDate(reason.occurredAt))} ` + : '') + reason.message, ), ); } diff --git a/packages/oss-console/src/components/Executions/Tables/NodeExecutionsTable.tsx b/packages/oss-console/src/components/Executions/Tables/NodeExecutionsTable.tsx index f8300f36d..0ad0362b4 100644 --- a/packages/oss-console/src/components/Executions/Tables/NodeExecutionsTable.tsx +++ b/packages/oss-console/src/components/Executions/Tables/NodeExecutionsTable.tsx @@ -254,18 +254,16 @@ export const NodeExecutionsTable: React.FC<{ {showNodes.length > 0 ? ( - showNodes.map((node) => { - return ( - - - - ); - }) + showNodes.map((node) => ( + + + + )) ) : ( )} diff --git a/packages/oss-console/src/components/Executions/Tables/WorkflowExecutionTable/cells.tsx b/packages/oss-console/src/components/Executions/Tables/WorkflowExecutionTable/cells.tsx index 735d3e246..c2490dfbc 100644 --- a/packages/oss-console/src/components/Executions/Tables/WorkflowExecutionTable/cells.tsx +++ b/packages/oss-console/src/components/Executions/Tables/WorkflowExecutionTable/cells.tsx @@ -16,7 +16,7 @@ import styled from '@mui/system/styled'; import { formatDateLocalTimezone, formatDateUTC, - formateDateRelative, + formatDateRelative, millisecondsToHMS, } from '../../../../common/formatters'; import { timestampToDate } from '../../../../common/utils'; @@ -83,7 +83,7 @@ export function getStartTimeCell( // const isArchived = isExecutionArchived(execution); if (isRelativeStartTime) { - return formateDateRelative(startedAtDate); + return formatDateRelative(startedAtDate); } const localTime = React.useMemo(() => { @@ -113,8 +113,8 @@ export function getStartTimeCell( } return `${h}h ${m}m ago`; } - return utc; - }, [startedAtDate, utc]); + return localTime; + }, [startedAtDate, localTime]); const tooltipText = React.useMemo(() => { const isLast24Hours = moment().diff(startedAtDate, 'hours') < 24; diff --git a/packages/oss-console/src/components/Executions/Tables/nodeExecutionColumns.tsx b/packages/oss-console/src/components/Executions/Tables/nodeExecutionColumns.tsx index 658b71569..a34abf9bd 100644 --- a/packages/oss-console/src/components/Executions/Tables/nodeExecutionColumns.tsx +++ b/packages/oss-console/src/components/Executions/Tables/nodeExecutionColumns.tsx @@ -123,10 +123,10 @@ export function generateColumns( return ( <> - {formatDateUTC(startedAtDate)} + {formatDateLocalTimezone(startedAtDate)} - {formatDateLocalTimezone(startedAtDate)} + {formatDateUTC(startedAtDate)} );