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/useFormatRelativeTime.ts

14 lines
476 B

import moment from 'moment';
import { useCallback } from 'react';
export const useFormatRelativeTime = (): ((timeMs: number) => string) =>
useCallback((timeMs: number) => {
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();
}, []);