Skip to content

Commit 1e41c58

Browse files
committed
fix: useTimeDistance.ts should use the test clock
1 parent 9cbe876 commit 1e41c58

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

webapp/src/hooks/useTimeDistance.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { useTranslate } from '@tolgee/react';
22
import { useDateFormatter } from 'tg.hooks/useLocale';
3+
import { useCurrentDate } from 'tg.hooks/useCurrentDate';
34

45
export function useTimeDistance() {
56
const { t } = useTranslate();
67
const formatDate = useDateFormatter();
8+
const currentDate = useCurrentDate();
79

810
return (timeInPast: number | string | Date) => {
911
const diffSeconds =
10-
(Date.now().valueOf() - new Date(timeInPast).valueOf()) / 1000;
12+
(currentDate.valueOf() - new Date(timeInPast).valueOf()) / 1000;
1113
const isFuture = diffSeconds < 0;
1214
const differenceInSeconds = Math.abs(diffSeconds);
1315

0 commit comments

Comments
 (0)