UNPKG

@selfcommunity/react-ui

Version:

React UI Components to integrate a Community created with SelfCommunity Platform.

32 lines (31 loc) 1.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.combineDateAndTime = exports.getLaterDaysDate = exports.getLaterHoursDate = exports.getNewDate = void 0; const date_fns_1 = require("date-fns"); function getNewDate(date) { if (date) { if (typeof date === 'string') { return new Date(date); } return date; } return new Date(); } exports.getNewDate = getNewDate; function getLaterHoursDate(hours, date) { return (0, date_fns_1.addHours)(getNewDate(date), hours); } exports.getLaterHoursDate = getLaterHoursDate; function getLaterDaysDate(days, date) { return (0, date_fns_1.addDays)(getNewDate(date), days); } exports.getLaterDaysDate = getLaterDaysDate; const combineDateAndTime = (date, time) => { const combined = date; combined.setHours(time.getHours()); combined.setMinutes(time.getMinutes()); combined.setSeconds(time.getSeconds()); combined.setMilliseconds(time.getMilliseconds()); return combined.toISOString(); }; exports.combineDateAndTime = combineDateAndTime;