import TimeSpan from "./TimeSpan"; /** * DateTime differs from Date in following cases, * 1. DateTime is immutable, however underlying object is Date * but all methods specific to DateTime are immutable * 2. DateTime has readonly properties for `day, month, year etc` * 3. DateTime is derived from Date so passing DateTime to existing * code will not change anything, however intellisense does not display * any methods of Date unless you explicity cast as Date, but instanceof * works correctly * 4. DateTime does not modify underlying Date prototype or add any methods to it * ``` typescript * DateTime dt = DateTime.now(); * (dt instanceof Date) // is true * (dt instanceof DateTime) // is also true * ``` */ export default class DateTime { /** * Returns DateTime new instance from Date or String, if d is DateTime already * it will return the d. * @param d Date | DateTime | string * @returns DateTime */ static from(d: Date | DateTime | string): DateTime; /** * Current date without time */ static get today(): DateTime; /** * Current UTC Date */ static get utcNow(): DateTime; /** * DateTime at right now */ static get now(): DateTime; static parse(s: string): DateTime; /** Day of month */ get day(): number; /** Day of week */ get dayOfWeek(): number; /** * Current month, 0 is January */ get month(): number; /** * Current full year */ get year(): number; /** * Current hour of the day */ get hour(): number; /** * Current minute of the hour */ get minute(): number; /** * Current second of the minute */ get second(): number; get milliSecond(): number; /** * Timezone offset as TimeSpan */ get timeZoneOffset(): TimeSpan; /** * Milliseconds since EPOCH, ie total number of milliseconds * of underlying Date object */ get msSinceEpoch(): number; /** * Strips time of the day and returns Date only */ get date(): DateTime; /** * Just for convenience, avoid using this, instead use methods of DateTime * or suggest better method at our github repo */ get asJSDate(): Date; /** * Gets time of the day in TimeSpan format */ get time(): TimeSpan; /** * Converts a date and time to a string by using the current or specified locale. * @param locales A locale string or array of locale strings that contain one or more language * or locale tags. If you include more than one locale string, list them in descending order of * priority so that the first entry is the preferred locale. If you omit this parameter, * the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleString: (locales?: string | string[], options?: Intl.DateTimeFormatOptions) => string; /** * Converts a date to a string by using the current or specified locale. * @param locales A locale string or array of locale strings that contain one or more language * or locale tags. If you include more than one locale string, list them in descending order * of priority so that the first entry is the preferred locale. If you omit this parameter, * the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleDateString: (locales?: string | string[], options?: Intl.DateTimeFormatOptions) => string; /** * Converts a time to a string by using the current or specified locale. * @param locales A locale string or array of locale strings that contain one or more language * or locale tags. If you include more than one locale string, list them in descending order of * priority so that the first entry is the preferred locale. If you omit this parameter, * the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleTimeString: (locales?: string | string[], options?: Intl.DateTimeFormatOptions) => string; /** Returns a date converted to a string using Universal Coordinated Time (UTC). */ toUTCString: () => string; /** Returns a date as a string value in ISO format. */ toISOString: () => string; /** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object * Notation (JSON) serialization. */ toJSON: (key?: any) => string; toTimeString: () => string; toDateString: () => string; /** * Creates new DateTime instance from given input, * input parameters are exactly same as `Date` */ constructor(a?: any | string, b?: number, c?: number, d?: number, e?: number, f?: number, g?: number); /** * Adds date or TimeSpan to current date and returns a new DateTime * @returns DateTime * @param d DateTime or TimeSpan */ add(d: DateTime | TimeSpan): DateTime; /** * Adds (or removes -ve values specified) and returns newly created DateTime * @returns DateTime * @param days number of days * @param hours number of hours * @param minutes number of minutes * @param seconds number of seconds * @param milliseconds number of milliseconds */ add(days: number, hours?: number, minutes?: number, seconds?: number, milliseconds?: number): DateTime; addMonths(m: number): DateTime; addYears(y: number): DateTime; addDays(day: number): DateTime; addHours(h: number): DateTime; addMinutes(m: number): DateTime; /** * Returns TimeSpan from subtracting rhs from this, * `const ts = lhs.diff(rhs); // ts = lhs - rhs` * @param rhs Right hand side * @returns TimeSpan */ diff(rhs: Date | DateTime): TimeSpan; equals(d: DateTime | Date): boolean; /** * Trims time part and compares the given dates * @param d date to test */ dateEquals(d: DateTime | Date): boolean; compare(d: DateTime | Date): number; toRelativeString(dt?: DateTime | Date): string; /** * Returns number so that DateTime in logical comparison * returns correct answer. Such as DateTime.from("2022-02-01") > DateTime.from("2021-02-01") returns true. * @returns Milliseconds since EPOCH */ valueOf(): number; } //# sourceMappingURL=DateTime.d.ts.map