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 { static readonly today: DateTime; static readonly utcNow: DateTime; static readonly now: DateTime; static parse(s: string): DateTime; readonly day: number; readonly dayOfWeek: number; readonly month: number; readonly year: number; readonly hour: number; readonly minute: number; readonly second: number; readonly milliSecond: number; readonly timeZoneOffset: TimeSpan; /** * Milliseconds since EPOCH, ie total number of milliseconds * of underlying Date object */ readonly msSinceEpoch: number; /** * Strips time of the day and returns Date only */ readonly date: DateTime; /** * Just for convenience, avoid using this, instead use methods of DateTime * or suggest better method at our github repo */ readonly asJSDate: Date; /** * Gets time of the day in TimeSpan format */ readonly 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; constructor(); constructor(time?: number | string); constructor(year?: number, month?: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: 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; /** * 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): boolean; } //# sourceMappingURL=DateTime.d.ts.map