import { ChacaUtils } from "../../core/utils"; import { DatatypeModule } from "../datatype"; export declare type ArgDate = Date | string; export declare type DateSoonProps = { days?: number; refDate?: ArgDate; }; export declare type DatePastProps = { years?: number; refDate?: ArgDate; }; export declare type AnytimeProps = { refDate?: ArgDate; }; export declare type DateFutureProps = { years?: number; refDate?: ArgDate; }; export declare type BirthDateProps = { refDate?: ArgDate; min?: number; max?: number; mode?: "age" | "year"; }; export declare type TimeUnits = "years" | "seconds" | "minutes" | "days" | "hours" | "months"; export declare type TimeAgoProps = { unit?: TimeUnits; }; export declare type DateBetweenProps = { from?: ArgDate; to?: ArgDate; }; export declare class DateModule { private readonly datatypeModule; private readonly utils; constructor(datatypeModule: DatatypeModule, utils: ChacaUtils); readonly constants: { weekDays: string[]; months: string[]; }; /** * Returns a date in the near future. * * @param args.days The range of days the date may be in the future. * @param args.refDate The date to use as reference point for the newly generated date. Defaults to now. * * @example * modules.date.soon() // '2022-02-05T09:55:39.216Z' * modules.date.soon({ days: 10 }) // '2022-02-11T05:14:39.138Z' */ soon({ days: idays, refDate: irefDate }?: DateSoonProps): Date; /** * Returns a Date in the past. * * @param args.years The range of years the date may be in the past. * @param args.refDate The date to use as reference point for the newly generated date. Defaults to now. * * @example * modules.date.past() // '2021-12-03T05:40:44.408Z' * modules.date.past()({ years: 10, refDate: '2020-01-01T00:00:00.000Z' }) // '2017-08-18T02:59:12.350Z' * * @returns Date * */ past({ refDate: irefDate, years: iyears }?: DatePastProps): Date; /** * Returns a date in the future. * * @param args.years The range of years the date may be in the future. * @param args.refDate The date to use as reference point for the newly generated date. Defaults to now. * * @example * modules.date.future() // '2022-11-19T05:52:49.100Z' * modules.date.future({ years: 10, refDate: '2020-01-01T00:00:00.000Z' }) // '2020-12-13T22:45:10.252Z' * * @returns Date */ future({ refDate: irefDate, years: iyears }?: DateFutureProps): Date; /** * Returns a month name * @example modules.date.month() // 'February' * @returns string */ month(): string; /** * Returns a weekday name * @example modules.date.weekDay() // 'Monday' * @returns string */ weekDay(): string; /** * Returns a random birthdate. * * @param args.min The minimum age or year to generate a birthdate. * @param args.max The maximum age or year to generate a birthdate. * @param args.refDate The date to use as reference point for the newly generated date. Defaults to `now`. * @param args.mode The mode to generate the birthdate. Supported modes are `'age'` and `'year'` . * * There are two modes available `'age'` and `'year'`: * - `'age'`: The min and max options define the age of the person (e.g. `18` - `42`). * - `'year'`: The min and max options define the range the birthdate may be in (e.g. `1900` - `2000`). * * Defaults to `year`. * * @example * modules.date.birthdate() // 1977-07-10T01:37:30.719Z * modules.date.birthdate({ min: 18, max: 65, mode: 'age' }) // 2003-11-02T20:03:20.116Z * modules.date.birthdate({ min: 1900, max: 2000, mode: 'year' }) // 1940-08-20T08:53:07.538Z * * @returns Date */ birthdate({ refDate: irefDate, max: imax, min: imin, mode: imode, }?: BirthDateProps): Date; private randomDate; /** * Returns a date between the given boundaries. * * @param args.from The early date boundary. * @param args.to The late date boundary. * * @example * modules.date.between({ from: '2020-01-01T00:00:00.000Z', to: '2030-01-01T00:00:00.000Z' }) // '2026-05-16T02:22:53.002Z' * * @returns Date */ between({ from: ifrom, to: ito }?: DateBetweenProps): Date; /** * Returns a string with a time ago information * @param args.unit Date time unit. Can be (`"years"` | `"seconds"` | `"minutes"` | `"days"` | `"hours"` | `"months"`) * @example modules.date.timeAgo({ unit: 'days' }) // '20 days ago' * @returns string */ timeAgo({ unit: iunit }?: TimeAgoProps): string; /** * Generates a random date that can be either in the past or in the future. * * @param args.refDate The date to use as reference point for the newly generated date. Defaults to `new Date()`. * * @example * modules.date.anytime() // '2022-07-31T01:33:29.567Z' */ anytime({ refDate }?: AnytimeProps): Date; private argToDate; }