diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/TableProfiler/TableProfilerProvider.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/TableProfiler/TableProfilerProvider.tsx index f7b50bf0afa..5611085bd5c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/TableProfiler/TableProfilerProvider.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/TableProfiler/TableProfilerProvider.tsx @@ -155,7 +155,7 @@ export const TableProfilerProvider = ({ value: profile?.createDateTime ? DateTime.fromJSDate(new Date(profile?.createDateTime)) .toUTC() - .toFormat('MMM dd, yyyy HH:mm') + .toLocaleString(DateTime.DATE_MED) : '--', }, ]; diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/TableProfilerUtils.ts b/openmetadata-ui/src/main/resources/ui/src/utils/TableProfilerUtils.ts index 0a715f4be34..b02b18c09ee 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/TableProfilerUtils.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/TableProfilerUtils.ts @@ -16,7 +16,10 @@ import { MetricChartType } from '../components/Database/Profiler/ProfilerDashboa import { SystemProfile } from '../generated/api/data/createTableProfile'; import { Table, TableProfile } from '../generated/entity/data/table'; import { CustomMetric } from '../generated/tests/customMetric'; -import { customFormatDateTime } from './date-time/DateTimeUtils'; +import { + customFormatDateTime, + DATE_TIME_12_HOUR_FORMAT, +} from './date-time/DateTimeUtils'; import { isHasKey } from './ObjectUtils'; import { CalculateColumnProfilerMetricsInterface, @@ -31,7 +34,10 @@ export const calculateRowCountMetrics = ( const rowCountMetricData: MetricChartType['data'] = []; updateProfilerData.forEach((data) => { - const timestamp = customFormatDateTime(data.timestamp, 'MMM dd, hh:mm'); + const timestamp = customFormatDateTime( + data.timestamp, + DATE_TIME_12_HOUR_FORMAT + ); rowCountMetricData.push({ name: timestamp, @@ -58,7 +64,10 @@ export const calculateSystemMetrics = ( const operationDateMetrics: MetricChartType['data'] = []; updateProfilerData.forEach((data) => { - const timestamp = customFormatDateTime(data.timestamp, 'MMM dd, hh:mm'); + const timestamp = customFormatDateTime( + data.timestamp, + DATE_TIME_12_HOUR_FORMAT + ); operationMetrics.push({ name: timestamp, @@ -94,7 +103,7 @@ export const calculateSystemMetrics = ( ...item, stackId: stackId, latestValue: operation?.timestamp - ? customFormatDateTime(operation?.timestamp, 'MMM dd, hh:mm') + ? customFormatDateTime(operation?.timestamp, DATE_TIME_12_HOUR_FORMAT) : '--', }; }); @@ -125,7 +134,10 @@ export const calculateCustomMetrics = ( }, {} as Record); updateProfilerData.forEach((data) => { - const timestamp = customFormatDateTime(data.timestamp, 'MMM dd, hh:mm'); + const timestamp = customFormatDateTime( + data.timestamp, + DATE_TIME_12_HOUR_FORMAT + ); data?.customMetrics?.forEach((metric) => { if (!isUndefined(metric.name)) { const updatedMetric = { @@ -167,7 +179,7 @@ export const calculateColumnProfilerMetrics = ({ const quartileMetricData: MetricChartType['data'] = []; updateProfilerData.forEach((col) => { const { timestamp, sum } = col; - const name = customFormatDateTime(timestamp, 'MMM dd, hh:mm'); + const name = customFormatDateTime(timestamp, DATE_TIME_12_HOUR_FORMAT); const defaultData = { name, timestamp }; if ( diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/date-time/DateTimeUtils.test.ts b/openmetadata-ui/src/main/resources/ui/src/utils/date-time/DateTimeUtils.test.ts index 917e0cf8a30..2a694342137 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/date-time/DateTimeUtils.test.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/date-time/DateTimeUtils.test.ts @@ -15,6 +15,7 @@ import { calculateInterval, convertMillisecondsToHumanReadableFormat, customFormatDateTime, + DATE_TIME_12_HOUR_FORMAT, formatDate, formatDateTime, formatDateTimeLong, @@ -58,6 +59,9 @@ describe('DateTimeUtils tests', () => { it(`customFormatDateTime should formate date and time both`, () => { expect(customFormatDateTime(0, 'yyyy/MM/dd')).toBe(`1970/01/01`); + expect(customFormatDateTime(0, DATE_TIME_12_HOUR_FORMAT)).toBe( + `Jan 01, 1970, 12:00 AM` + ); }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/date-time/DateTimeUtils.ts b/openmetadata-ui/src/main/resources/ui/src/utils/date-time/DateTimeUtils.ts index 2a42ce1fb05..991badc7c21 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/date-time/DateTimeUtils.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/date-time/DateTimeUtils.ts @@ -13,6 +13,8 @@ import { capitalize, isNil, toInteger, toNumber } from 'lodash'; import { DateTime, Duration } from 'luxon'; +export const DATE_TIME_12_HOUR_FORMAT = 'MMM dd, yyyy, hh:mm a'; // e.g. Jan 01, 12:00 AM + /** * @param date EPOCH millis * @returns Formatted date for valid input. Format: MMM DD, YYYY, HH:MM AM/PM