UNPKG

rich-domain

Version:

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

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