* refactor: 💡 use Hds::Time component * refactor: 💡 fix data test selector * refactor: 💡 standardardized date/time format * refactor: 💡 fix tests and remove date helpers * fix: 🐛 fixed helper test import
23 lines
524 B
JavaScript
23 lines
524 B
JavaScript
/**
|
|
* Copyright IBM Corp. 2021, 2026
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
/**
|
|
* Formats a date string into a user-friendly date/time format.
|
|
* Example: Jan 1, 2024, 12:00:00 AM GMT
|
|
* @param {date string} value
|
|
* @returns
|
|
*/
|
|
export const formatDateUserFriendly = (value) =>
|
|
new Intl.DateTimeFormat('en-US', {
|
|
month: 'short',
|
|
day: 'numeric',
|
|
year: 'numeric',
|
|
hour: 'numeric',
|
|
minute: '2-digit',
|
|
second: '2-digit',
|
|
hour12: true,
|
|
timeZoneName: 'short',
|
|
}).format(new Date(value));
|