UNPKG

@hitachivantara/uikit-react-core

Version:

Core React components for the NEXT Design System.

35 lines (34 loc) 695 B
import dayjs from "dayjs"; const padTime = (value) => { if (!value || value < 0) { return "00"; } if (value < 10 && value.toString().length === 1) { return `0${value.toString()}`; } return value.toString(); }; const parseDate = (date) => { if (date != null) { return dayjs(date).toDate(); } return void 0; }; const parseTime = (time) => { if (time != null) { const parts = time.split(":"); if (parts.length === 3) { return { hours: Number.parseInt(parts[0], 10), minutes: Number.parseInt(parts[1], 10), seconds: Number.parseInt(parts[2], 10) }; } } return null; }; export { padTime, parseDate, parseTime };