Drying out

This commit is contained in:
2026-05-27 15:18:29 +02:00
parent 7cef6da5f2
commit 3e8a2092cd
8 changed files with 89 additions and 106 deletions
@@ -1,23 +1,11 @@
import React, { useState, useEffect } from 'react';
import { toLocalDatetimeInputValue, toUTCFromLocalInput } from '../../utils/time';
interface TimeAdjusterProps {
onTimeChange: (time: string) => void;
defaultValue?: string;
}
function toLocalDatetimeInputValue(date: Date): string {
const pad = (n: number) => String(n).padStart(2, '0');
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`;
}
function toUTCFromLocalInput(inputValue: string): string {
const [datePart, timePart] = inputValue.split('T');
const [year, month, day] = datePart.split('-').map(Number);
const [hours, minutes] = timePart.split(':').map(Number);
const localDate = new Date(year, month - 1, day, hours, minutes);
return localDate.toISOString();
}
const TimeAdjuster: React.FC<TimeAdjusterProps> = ({ onTimeChange, defaultValue }) => {
const [value, setValue] = useState(() => {
if (defaultValue) {