UNPKG

rich-domain

Version:

This package provide utils file and interfaces to assistant build a complex application with domain driving design

26 lines 1.1 kB
import { Unit } from "../types"; /** * @description Increments a given date by a specified amount of time based on the unit provided. * * @param date The starting date to increment. * @param value The number of units to increment. If not a valid number, the original timestamp is returned. * @param unit The unit of time to increment. Possible values are: * - `'day'`: Increment by days. * - `'hour'`: Increment by hours. * - `'minute'`: Increment by minutes. * - `'month'`: Increment by months. * - `'week'`: Increment by weeks. * - `'year'`: Increment by years. * * @returns The incremented timestamp as a number. If the input date is invalid, the current timestamp is returned. * * @example * ```typescript * const now = new Date(); * const incrementedTime = IncrementTime(now, 3, 'day'); // Adds 3 days to the current date. * console.log(new Date(incrementedTime)); // Logs the incremented date. * ``` */ export declare const IncrementTime: (date: Date, value: number, unit: Unit) => number; export default IncrementTime; //# sourceMappingURL=increment-time.util.d.ts.map