diff --git a/src/components/scroll/ScrollParamForm.tsx b/src/components/scroll/ScrollParamForm.tsx index b3f858b..f2ffabb 100644 --- a/src/components/scroll/ScrollParamForm.tsx +++ b/src/components/scroll/ScrollParamForm.tsx @@ -2,8 +2,76 @@ import { Settings } from "lucide-react"; import { PARAM_CONFIG } from "@/components/nostr/kinds/ScrollRenderer"; import { Label } from "@/components/ui/label"; import { Input } from "@/components/ui/input"; +import { formatTimestamp } from "@/hooks/useLocale"; import type { ScrollParam } from "@/lib/nip5c-helpers"; +const TIMESTAMP_PRESETS = [ + { label: "1h ago", offset: 3600 }, + { label: "1d ago", offset: 86400 }, + { label: "1w ago", offset: 604800 }, + { label: "1mo ago", offset: 2592000 }, +] as const; + +function unixToDatetimeLocal(unixSeconds: number): string { + const date = new Date(unixSeconds * 1000); + // toISOString gives UTC; adjust to local time for datetime-local input + const offset = date.getTimezoneOffset() * 60000; + return new Date(date.getTime() - offset).toISOString().slice(0, 16); +} + +function TimestampInput({ + value, + onChange, + disabled, +}: { + value: string; + onChange: (value: string) => void; + disabled?: boolean; +}) { + const numericValue = value ? parseInt(value, 10) : null; + const datetimeValue = + numericValue && !isNaN(numericValue) + ? unixToDatetimeLocal(numericValue) + : ""; + + return ( +