There was an error while loading. Please reload this page.
1 parent 9cbe876 commit 1e41c58Copy full SHA for 1e41c58
1 file changed
webapp/src/hooks/useTimeDistance.ts
@@ -1,13 +1,15 @@
1
import { useTranslate } from '@tolgee/react';
2
import { useDateFormatter } from 'tg.hooks/useLocale';
3
+import { useCurrentDate } from 'tg.hooks/useCurrentDate';
4
5
export function useTimeDistance() {
6
const { t } = useTranslate();
7
const formatDate = useDateFormatter();
8
+ const currentDate = useCurrentDate();
9
10
return (timeInPast: number | string | Date) => {
11
const diffSeconds =
- (Date.now().valueOf() - new Date(timeInPast).valueOf()) / 1000;
12
+ (currentDate.valueOf() - new Date(timeInPast).valueOf()) / 1000;
13
const isFuture = diffSeconds < 0;
14
const differenceInSeconds = Math.abs(diffSeconds);
15
0 commit comments