mirror of
https://github.com/aljazceru/rabbit.git
synced 2025-12-18 22:44:26 +01:00
update
This commit is contained in:
11
src/hooks/useFileInput.ts
Normal file
11
src/hooks/useFileInput.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { createSignal, type JSX } from 'solid-js';
|
||||
|
||||
const useFileInput = () => {
|
||||
const [file, setFile] = createSignal<File | undefined>();
|
||||
|
||||
const handleChange: JSX.EventHandler<HTMLInputElement, Event> = (ev) => {
|
||||
setFile(ev.currentTarget.files?.[0]);
|
||||
};
|
||||
|
||||
return { file, handleChange };
|
||||
};
|
||||
@@ -1,20 +1,24 @@
|
||||
import { createMemo } from 'solid-js';
|
||||
|
||||
import useConfig from '@/nostr/useConfig';
|
||||
|
||||
import useDatePulser from '@/hooks/useDatePulser';
|
||||
|
||||
import { formatRelative, formatAbsolute } from '@/utils/formatDate';
|
||||
import { formatRelative, formatAbsoluteLong, formatAbsoluteShort } from '@/utils/formatDate';
|
||||
|
||||
const useFormatDate = () => {
|
||||
const { config } = useConfig();
|
||||
const currentDate = useDatePulser();
|
||||
|
||||
return (date: Date) => {
|
||||
if (config().dateFormat === 'absolute') {
|
||||
return formatAbsolute(date);
|
||||
switch (config().dateFormat) {
|
||||
case 'absolute-long':
|
||||
return formatAbsoluteLong(date, currentDate());
|
||||
case 'absolute-short':
|
||||
return formatAbsoluteShort(date, currentDate());
|
||||
case 'relative':
|
||||
return formatRelative(date, currentDate());
|
||||
default:
|
||||
return formatRelative(date, currentDate());
|
||||
}
|
||||
return formatRelative(date, currentDate());
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user