mirror of
https://github.com/aljazceru/rabbit.git
synced 2025-12-19 06:54:23 +01:00
update
This commit is contained in:
21
src/hooks/useFormatDate.ts
Normal file
21
src/hooks/useFormatDate.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { createMemo } from 'solid-js';
|
||||
|
||||
import useConfig from '@/nostr/useConfig';
|
||||
|
||||
import useDatePulser from '@/hooks/useDatePulser';
|
||||
|
||||
import { formatRelative, formatAbsolute } from '@/utils/formatDate';
|
||||
|
||||
const useFormatDate = () => {
|
||||
const { config } = useConfig();
|
||||
const currentDate = useDatePulser();
|
||||
|
||||
return (date: Date) => {
|
||||
if (config().dateFormat === 'absolute') {
|
||||
return formatAbsolute(date);
|
||||
}
|
||||
return formatRelative(date, currentDate());
|
||||
};
|
||||
};
|
||||
|
||||
export default useFormatDate;
|
||||
Reference in New Issue
Block a user