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/apps/meteor/client/hooks/useFormattedRelativeTime.ts

14 lines
455 B

import moment from 'moment';
import { useMemo } from 'react';
export const useFormattedRelativeTime = (timeMs: number): string =>
useMemo(() => {
moment.relativeTimeThreshold('s', 60);
moment.relativeTimeThreshold('ss', 0);
moment.relativeTimeThreshold('m', 60);
moment.relativeTimeThreshold('h', 24);
moment.relativeTimeThreshold('d', 31);
moment.relativeTimeThreshold('M', 12);
return moment.duration(timeMs).humanize();
}, [timeMs]);