react-time-picker
Version:
A time picker for your React app.
13 lines (12 loc) • 771 B
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { getHours, getMinutes, getSeconds } from '@wojtekmaj/date-utils';
import Input from './Input.js';
import { safeMax, safeMin } from '../shared/utils.js';
export default function SecondInput({ hour, maxTime, minTime, minute, showLeadingZeros = true, ...otherProps }) {
function isSameMinute(date) {
return hour === getHours(date).toString() && minute === getMinutes(date).toString();
}
const maxSecond = safeMin(59, maxTime && isSameMinute(maxTime) && getSeconds(maxTime));
const minSecond = safeMax(0, minTime && isSameMinute(minTime) && getSeconds(minTime));
return (_jsx(Input, { max: maxSecond, min: minSecond, name: "second", showLeadingZeros: showLeadingZeros, ...otherProps }));
}