UNPKG

@brightsoftware/date-np

Version:

Simple & minimal Nepali date picker that just works.

105 lines (104 loc) 2.57 kB
/** * NepaliDate class for handling Nepali (Bikram Sambat) dates * This class provides Date-like functionality but works with the Nepali calendar system */ export declare class NepaliDate { private _year; private _month; private _date; constructor(); constructor(year: number, month: number, date?: number); constructor(adDate: Date); constructor(nepaliDate: NepaliDate); constructor(dateString: string); /** * Normalize the date to handle overflow/underflow of dates and months */ private normalize; /** * Get the year (BS) */ getFullYear(): number; /** * Get the month (0-based, like JavaScript Date) */ getMonth(): number; /** * Get the date */ getDate(): number; /** * Get the day of the week (0 = Sunday, 6 = Saturday) * This converts to AD date to get the correct day */ getDay(): number; /** * Set the year */ setFullYear(year: number): void; /** * Set the month (0-based) */ setMonth(month: number): void; /** * Set the date */ setDate(date: number): void; /** * Get the number of days in the current month */ getDaysInMonth(): number; /** * Get the number of days in a specific month of the current year */ getDaysInMonthOf(month: number): number; /** * Create a new NepaliDate with the first day of the current month */ getFirstDayOfMonth(): NepaliDate; /** * Create a new NepaliDate with the last day of the current month */ getLastDayOfMonth(): NepaliDate; /** * Add days to the current date */ addDays(days: number): NepaliDate; /** * Add months to the current date */ addMonths(months: number): NepaliDate; /** * Add years to the current date */ addYears(years: number): NepaliDate; /** * Check if this date equals another date */ equals(other: NepaliDate): boolean; /** * Compare this date with another date * Returns: -1 if this < other, 0 if equal, 1 if this > other */ compare(other: NepaliDate): number; /** * Convert to AD Date */ toADDate(): Date; /** * Create NepaliDate from AD Date */ static fromADDate(adDate: Date): NepaliDate; /** * Get today's Nepali date */ static today(): NepaliDate; /** * String representation */ toString(): string; /** * Create a clone of this date */ clone(): NepaliDate; }