/** * Represents a Gregorian date/time in Nepal's timezone (Asia/Kathmandu, UTC+05:45). * Behaves like a JavaScript `Date` object, with all getters returning values in Nepal's timezone. * Does not convert to the Nepali (Bikram Sambat) calendar. * * @example * const date = new NepalTimezoneDate(); * or, * const date = new NepalTimezoneDate(2024, 11, 28, 20, 45, 35) // 20:45 is Nepal time * date.toString() // "2024-12-28 20:45:35 GMT+0545" * date.toDate() // JS Date object in UTC * * @example * const date = new NepalTimezoneDate(new Date()) * date.getYear() // Nepal year * date.getMinutes() // Nepal minutes */ declare class NepalTimezoneDate { private _date; private _nepalTimezoneSafeDate; /** * Get the Nepali date and time components (Gregorian calendar) from a given date. * The input can be any date from any timezone, it is converted into the Nepal's timezone (Asia/Kathmandu). * * @param date - The input date for which to retrieve the Nepali date and time. * @returns An object containing the Nepali date and time components. */ private static getNepalDateAndTime; /** * Get the Date object from the given Nepali date and time components. * * @param year - The year component of the Nepali date. * @param month - The month component of the Nepali date (0-11). * @param date - The day component of the Nepali date. * @param hour - The hour component of the Nepali time. * @param minute - The minute component of the Nepali time. * @param second - The second component of the Nepali time. * @param ms - The millisecond component of the Nepali time. * @returns A `Date` object representing the UTC date and time. */ private static getDate; /** * Creates a NepalTimezoneDate instance for Asia/Kathmandu timezone (UTC+05:45). * Accepts: * - No arguments (current date/time) * - Unix epoch (number) * - Date object * - year, month, ... (Nepal timezone components) */ constructor(...args: any[]); /** * Retrieves the year in Nepal's timezone (Gregorian calendar). * @returns {number} The full numeric value representing the year */ getYear(): number; /** * Retrieves the month in Nepal's timezone (Gregorian calendar). * @returns {number} The numeric value representing the month */ getMonth(): number; /** * Retrieves the day of the month in Nepal's timezone (Gregorian calendar). * @returns {number} The numeric value representing the day of the month. */ getDate(): number; /** * Retrieves the hour in Nepal's timezone. * @returns {number} The numeric value representing the hour */ getHours(): number; /** * Retrieves the minute in Nepal's timezone. * @returns {number} The numeric value representing the minute */ getMinutes(): number; /** * Retrieves the second in Nepal's timezone. * @returns {number} The numeric value representing the second */ getSeconds(): number; /** * Retrieves the millisecond in Nepal's timezone. * @returns {number} The numeric value representing the millisecond */ getMilliseconds(): number; /** * Retrieves the day of the week in Nepal's timezone. * @returns {number} The numeric value representing the day of the week */ getDay(): number; /** * Retrieves the Unix timestamp (in milliseconds) of the date. * @returns {number} The numeric value representing the time in milliseconds. */ getTime(): number; /** * Returns a string representation of the NepalTimezoneDate object in Nepal's timezone. * @returns {string} The string representation in the format "YYYY-MM-DD HH:mm:ss GMT+0545". */ toString(): string; /** * Returns the underlying Date object (UTC). * @returns {Date} The equivalent JavaScript Date object. */ toDate(): Date; } /** * Represents a Nepali calendar date. */ declare class NepaliDate { private timestamp; private year; private yearEn; private month; private monthEn; private day; private dayEn; private hour; private minute; private weekDay; /** * Creates a NepaliDate instance for the current date and time. * * @example * const now = new NepaliDate() */ constructor(); /** * Creates a NepaliDate instance from a provided Javascript Date object. * * @param {Date} date - The Javascript Date object. * * @example * const jsDate = new Date("2020-01-01") * const nepaliDate = new NepaliDate(jsDate) */ constructor(date: Date); /** * Creates a new NepaliDate instance from another NepaliDate object. * * @param {NepaliDate} date - The NepaliDate object. * @example * const nepaliDateOld = new NepaliDate('2080-01-01') * const nepaliDate = new NepaliDate(nepaliDateOld) */ constructor(date: NepaliDate); /** * Creates a NepaliDate instance by parsing a provided date-time string. * * @param {string} value - The date-time string. * @example * const nepaliDate = new NepaliDate('2080-01-01') */ constructor(value: string); /** * Creates a NepaliDate instance from a provided Unix timestamp. * * @param {number} value - The Unix timestamp. * @example * const timestamp = 1695569762 // Unix timestamp in milliseconds * const nepaliDate = new NepaliDate(timestamp) */ constructor(value: number); /** * Creates a NepaliDate instance by parsing a provided date-time string * with the given format. * * @param dateString - The date-time string to parse. * @param format - The format of the provided date-time string. * @example * const dateTimeString = '2080/08/12 14-05-23.789' * const format = 'YYYY/MM/DD HH-mm-ss.SSS' * const nepaliDate = new NepaliDate(dateTimeString, format) */ constructor(dateString: string, format: string); /** * Creates a NepaliDate instance from a provided Nepali calendar date components. * * @constructor * @param {number} year - The year (e.g., 2080). * @param {number} month - The month (0-11, where 0 is Baisakh and 11 is Chaitra). * @param {number} [day=1] - The day of the month (1-31). * @param {number} [hour=0] - The hour of the day (0-23). * @param {number} [minute=0] - The minute (0-59). * @param {number} [second=0] - The second (0-59). * @param {number} [ms=0] - The milliseconds (0-999). * * @example * const year = 2080 * const month = 1 // Jestha * const day = 12 * const hour = 12 * const minute = 30 * const second = 45 * const ms = 500 * const nepaliDate = new NepaliDate(year, month, day, hour, minute, second, ms) */ constructor(year: number, month: number, day?: number, hour?: number, minute?: number, second?: number, ms?: number); /** * Creates a NepaliDate instance from a NepalTimezoneDate object. * * @param {NepalTimezoneDate} date - The NepalTimezoneDate object. * @example * const npTzDate = new NepalTimezoneDate('2024-12-28T15:00:35Z') * const nepaliDate = new NepaliDate(npTzDate) */ constructor(date: NepalTimezoneDate); private initFromCurrentDate; private initFromEnglishDate; private initFromNepaliDate; private parseFromString; private initFromTimestamp; private parseFromStringWithFormat; private initFromComponents; /** * Sets the English date and optionally computes the corresponding Nepali date. * Handles all the operations and variables while setting the English date. * * @param date The English date to set. * @param computeNepaliDate Flag indicating whether to compute the Nepali date. Default is `true`. * @returns void */ private _setDateObject; /** * Retrieves the Date object equivalent to the NepaliDate. * * @returns {Date} The equivalent JavaScript Date object. */ getDateObject(): Date; /** * Retrieves the year of the Nepali date in the Nepali calendar. * * @returns {number} The full numeric value representing the year. Eg. 2080 */ getYear(): number; /** * Retrieves the year of the Nepali date in the English calendar. * * @returns {number} The full numeric value representing the year. Eg. 2009 */ getEnglishYear(): number; /** * Retrieves the month of the Nepali date in the Nepali calendar. * * @returns {number} The numeric value representing the month. 0 for Baisakh and 11 for Chaitra. */ getMonth(): number; /** * Retrieves the month of the Nepali date in the English calendar. * * @returns {number} The numeric value representing the month. 0 for January and 11 for December. */ getEnglishMonth(): number; /** * Retrieves the day of the month represented of Nepali date in Nepali calendar. * * @returns {number} The numeric value representing the day of the month. */ getDate(): number; /** * Retrieves the day of the month represented of Nepali date in English calendar. * * @returns {number} The numeric value representing the day of the month. */ getEnglishDate(): number; /** * Retrieves the day of the week represented by a numeric value. * * @returns The numeric value representing the day of the week. * 0: Sunday * 1: Monday * 2: Tuesday * 3: Wednesday * 4: Thursday * 5: Friday * 6: Saturday */ getDay(): number; /** * Retrieves the hour value of the Nepali date. * * @returns {number} The numeric value representing the hour. */ getHours(): number; /** * Retrieves the minute value of the Nepali date. * * @returns {number} The numeric value representing the minute. */ getMinutes(): number; /** * Retrieves the second value of the Nepali date. * * @returns {number} The numeric value representing the second. */ getSeconds(): number; /** * Retrieves the millisecond value of the Nepali date. * * @returns {number} The numeric value representing the millisecond. */ getMilliseconds(): number; /** * Retrieves the unix timestamp (in milliseconds) of the Nepali date. * * @returns {number} The numeric value representing the time in milliseconds. */ getTime(): number; /** * Sets the day on the current date and time * * @param {number} year - The numeric value representing the year. * @throws {ValidationError} if year is out of range */ setYear(year: number): void; /** * Sets the day on the current date and time * * @param {number} month - The numeric value representing the month. * @throws {ValidationError} if month is out of range */ setMonth(month: number): void; /** * Sets the day on the current date and time * * @param {number} day - The numeric value representing the day. * @throws {ValidationError} if day is out of range */ setDate(day: number): void; /** * Sets hour on the current date and time * * @param hour Hour to set * @throws {ValidationError} if hour is out of range */ setHours(hour: number): void; /** * Sets minute on the current date and time * * @param minute Minute to set * @throws {ValidationError} if minute is out of range */ setMinutes(minute: number): void; /** * Sets second on the current date and time * * @param second Second to set * @throws {ValidationError} if second is out of range */ setSeconds(second: number): void; /** * Sets milliseconds on the current date and time * * @param ms Milliseconds to set * @throws {ValidationError} if milliseconds is out of range */ setMilliseconds(ms: number): void; /** * Sets time on the object. * * @param time Time to set (timestamp) */ setTime(time: number): void; /** * Sets the Nepali date and time values. * * @param {number} year - The numeric value representing the year. * @param {number} month - The numeric value representing the month. * @param {number} date - The numeric value representing the day. * @param {number} [hour=0] - The numeric value representing the hour. * @param {number} [minute=0] - The numeric value representing the minute. * @param {number} [second=0] - The numeric value representing the second. * @param {number} [ms=0] - The numeric value representing the millisecond. */ set(year: number, month: number, date: number, hour: number, minute: number, second: number, ms: number): void; /** * Sets the Date object on the current NepaliDate object. * * @param date The Date object to set. * @returns void */ setDateObject(date: Date): void; /** * Returns a string representation (in English) of the NepaliDate object in the specified format. * * @param {string} formatStr - The format string specifying the desired format. * @returns {string} The formatted Nepali date string. */ format(formatStr: string): string; /** * Returns a string representation in the Nepali (Devanagari) of the NepaliDate object in the specified format. * @param formatStr The format string for the desired output. * @returns {string} The formatted Date string in Nepali (Devanagari). */ formatNepali(formatStr: string): string; /** * Returns a string representation of the NepaliDate object. * * @returns {string} The string representation of the Nepali date. */ toString(): string; /** * Returns a string representation (in English) of the English Date in the specified format. * * @param {string} formatStr - The format string specifying the desired format. * @returns {string} The formatted Date string. */ formatEnglishDate(formatStr: string): string; /** * Returns a string representation in the Nepali (Devanagari) of the English Date in the specified format. * @param formatStr The format string for the desired output. * @returns {string} The formatted Date string in Nepali (Devanagari). */ formatEnglishDateInNepali(formatStr: string): string; /** * Creates a new instance of NepaliDate from an English calendar parameters. * * @param year - The year in English calendar format. * @param month - The month (0-11) in English calendar format. * @param date - The day of the month in English calendar format. * @param hour - The hour (0-23) in English calendar format. Default is 0. * @param minute - The minute (0-59) in English calendar format. Default is 0. * @param second - The second (0-59) in English calendar format. Default is 0. * @param ms - The millisecond (0-999) in English calendar format. Default is 0. * @returns A new instance of NepaliDate corresponding to the provided English date. */ static fromEnglishDate(year: number, month: number, date: number, hour?: number, minute?: number, second?: number, ms?: number): NepaliDate; /** * Parses a Nepali date-time string in Devanagari form according to the * specified format and returns a `NepaliDate` instance. * * @param dateStringNe - The Nepali Date and time string in Devanagari. * @param format - The format of the provided date-time string. * @example * const dateStringNe = '२०८०/०८/१२ १४-०५-२३.७८९' * const format = 'YYYY/MM/DD HH-mm-ss.SSS' * const nepaliDate = NepaliDate.parseNepaliFormat(dateStringNe, format) */ static parseNepaliFormat(dateStringNe: string, format: string): NepaliDate; /** * Parses an English date-time string according to the specified format * and returns a `NepaliDate` instance. * * @param dateString - The English Date and time string. * @param format - The format of the provided date-time string. * @example * const dateTimeString = '2024/11/23 14-05-23.789' * const format = 'YYYY/MM/DD HH-mm-ss.SSS' * const nepaliDate = NepaliDate.parseEnglishDate(dateTimeString, format) */ static parseEnglishDate(dateString: string, format: string): NepaliDate; /** * Returns the number of days in a specific month of a given year. * * @param year - The year to fetch the month from. * @param month - The month to get the number of days for. * @returns The number of days in the specified month. * @throws {Error} If the year or month is out of range. */ static getDaysOfMonth(year: number, month: number): number; /** * Returns the minimum supported JS Date object. * * @returns {Date} The minimum supported JS Date object. */ static minSupportedDate(): Date; /** * Returns the maximum supported JS Date object. * * @returns {Date} The maximum supported JS Date object. */ static maxSupportedDate(): Date; /** * Returns the minimum supported NepaliDate object. * * @returns {Date} The minimum supported NepaliDate object. */ static minSupportedNepaliDate(): NepaliDate; /** * Returns the maximum supported NepaliDate object. * * @returns {Date} The maximum supported NepaliDate object. */ static maxSupportedNepaliDate(): NepaliDate; static minimum(): Date; static maximum(): Date; } // @ts-ignore export = NepaliDate; export { NepalTimezoneDate };