feat: introduce voice call dashboard (#14954)
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import {
|
||||
format,
|
||||
isSameYear,
|
||||
isThisYear,
|
||||
isToday,
|
||||
isYesterday,
|
||||
fromUnixTime,
|
||||
formatDistanceToNow,
|
||||
differenceInDays,
|
||||
@@ -33,6 +36,22 @@ export const messageTimestamp = (time, dateFormat = 'MMM d, yyyy') => {
|
||||
return messageDate;
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats a Unix timestamp relative to today: the time for today, a caller-
|
||||
* supplied label for yesterday, and a date otherwise. The yesterday label is
|
||||
* passed in so the caller keeps ownership of translation.
|
||||
* @param {number} time - Unix timestamp.
|
||||
* @param {string} yesterdayLabel - Localized label shown for yesterday.
|
||||
* @returns {string} Formatted timestamp string.
|
||||
*/
|
||||
export const relativeDayTimestamp = (time, yesterdayLabel) => {
|
||||
const date = fromUnixTime(time);
|
||||
if (isToday(date)) return format(date, 'h:mm a');
|
||||
if (isYesterday(date)) return yesterdayLabel;
|
||||
if (isThisYear(date)) return format(date, 'MMM d');
|
||||
return format(date, 'MMM d, yyyy');
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a Unix timestamp to a relative time string (e.g., 3 hours ago).
|
||||
* @param {number} time - Unix timestamp.
|
||||
|
||||
Reference in New Issue
Block a user