The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Rocket.Chat/client/hooks/useTimeAgo.js

22 lines
509 B

import moment from 'moment';
import { useCallback } from 'react';
export const useTimeAgo = () =>
useCallback((time) => moment(time).calendar(null, { sameDay: 'LT', lastWeek: 'dddd LT', sameElse: 'LL' }), []);
export const useShortTimeAgo = () =>
useCallback(
(time) =>
moment(time).calendar(null, {
sameDay: 'LT',
lastDay: '[Yesterday]',
lastWeek: 'dddd',
sameElse(now) {
if (this.isBefore(now, 'year')) {
return 'LL';
}
return 'MMM Do';
},
}),
[],
);