mirror of
https://github.com/owncast/owncast.git
synced 2024-12-18 23:32:51 +03:00
e50b23d081
* chore(js): be stricter about dead code warnings * chore(js): remove dead code and unused exports * rebase * chore: remove unused files * chore(deps): remove unused prop-types dep * chore(js): remove unused function * chore(deps): remove + check unused deps * chore(js): remove unused exports. Closes #3036
17 lines
456 B
TypeScript
17 lines
456 B
TypeScript
import { getDiffInDaysFromNow } from '../../../utils/helpers';
|
|
|
|
export function formatTimestamp(sentAt: Date) {
|
|
const now = new Date(sentAt);
|
|
if (Number.isNaN(now)) return '';
|
|
|
|
const diffInDays = getDiffInDaysFromNow(sentAt);
|
|
|
|
if (diffInDays >= 1) {
|
|
const localeDate = now.toLocaleDateString('en-US', {
|
|
dateStyle: 'medium',
|
|
});
|
|
return `${localeDate} at ${now.toLocaleTimeString()}`;
|
|
}
|
|
|
|
return `${now.toLocaleTimeString()}`;
|
|
}
|