UNPKG

@selfcommunity/react-ui

Version:

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

25 lines (24 loc) 723 B
import { addDays, addHours } from 'date-fns'; export function getNewDate(date) { if (date) { if (typeof date === 'string') { return new Date(date); } return date; } return new Date(); } export function getLaterHoursDate(hours, date) { return addHours(getNewDate(date), hours); } export function getLaterDaysDate(days, date) { return addDays(getNewDate(date), days); } export 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(); };