refactoring
This commit is contained in:
@@ -278,3 +278,15 @@ export function convertOnPaste( event = { preventDefault() {} }) {
|
||||
document.execCommand('insertText', false, value);
|
||||
}
|
||||
}
|
||||
|
||||
export function formatTimestamp(sentAt) {
|
||||
sentAt = new Date(sentAt);
|
||||
|
||||
let diffInDays = ((new Date()) - sentAt) / (24 * 3600 * 1000);
|
||||
if (diffInDays >= -1) {
|
||||
return `${sentAt.toLocaleDateString('en-US', {dateStyle: 'medium'})} at ` +
|
||||
sentAt.toLocaleTimeString();
|
||||
}
|
||||
|
||||
return sentAt.toLocaleTimeString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user