|
| 1 | +/** |
| 2 | + * Represents a Nepali calendar date. |
| 3 | + */ |
1 | 4 | declare class NepaliDate {
|
2 | 5 | timestamp: Date;
|
3 | 6 | year: number;
|
| 7 | + yearEn: number; |
4 | 8 | month: number;
|
| 9 | + monthEn: number; |
5 | 10 | day: number;
|
| 11 | + dayEn: number; |
| 12 | + hour: number; |
| 13 | + minute: number; |
| 14 | + weekDay: number; |
6 | 15 | static minimum: () => Date;
|
7 | 16 | static maximum: () => Date;
|
| 17 | + /** |
| 18 | + * Creates a new NepaliDate object. |
| 19 | + * |
| 20 | + * @param args - The arguments to create the NepaliDate object. |
| 21 | + * |
| 22 | + * Examples Parameters: |
| 23 | + * - No parameters: Creates a NepaliDate object for the current date and time. |
| 24 | + * ``` |
| 25 | + * const now = new NepaliDate(); |
| 26 | + * ``` |
| 27 | + * |
| 28 | + * - Nepali date time string: Parses the string as a Nepali calendar date. |
| 29 | + * ``` |
| 30 | + * const date1 = new NepaliDate('2079-02-15'); |
| 31 | + * const date2 = new NepaliDate('2079-02-15 14:00'); |
| 32 | + * ``` |
| 33 | + * |
| 34 | + * - Unix timestamp (in milliseconds): |
| 35 | + * ``` |
| 36 | + * const date2 = new NepaliDate(1654210800000); |
| 37 | + * ``` |
| 38 | + * |
| 39 | + * - Date object: Converts the JavaScript Date object to a NepaliDate object. |
| 40 | + * ``` |
| 41 | + * const jsDate = new Date(); |
| 42 | + * const date3 = new NepaliDate(jsDate); |
| 43 | + * ``` |
| 44 | + * |
| 45 | + * - NepaliDate object: Creates a new NepaliDate object with the same values. |
| 46 | + * ``` |
| 47 | + * const date4 = new NepaliDate(date3); |
| 48 | + * ``` |
| 49 | + * |
| 50 | + * - Nepali calendar date and time parameters: Specifies the components of a Nepali calendar date. |
| 51 | + * ``` |
| 52 | + * const date5 = new NepaliDate(2079, 2, 15, 10, 30); |
| 53 | + * ``` |
| 54 | + * |
| 55 | + * @throws {Error} If an invalid date argument is provided. |
| 56 | + */ |
8 | 57 | constructor(...args: any[]);
|
9 |
| - setEnglishDate(date: Date): void; |
10 |
| - getEnglishDate(): Date; |
11 |
| - parse(dateString: string): void; |
| 58 | + /** |
| 59 | + * Sets the English date and optionally computes the corresponding Nepali date. |
| 60 | + * Handles all the operations and variables while setting the English date. |
| 61 | + * |
| 62 | + * @param date The English date to set. |
| 63 | + * @param computeNepaliDate Flag indicating whether to compute the Nepali date. Default is `false`. |
| 64 | + * @returns void |
| 65 | + */ |
| 66 | + private _setDateObject; |
| 67 | + /** |
| 68 | + * Retrieves the Date object equivalent to the NepaliDate. |
| 69 | + * |
| 70 | + * @returns {Date} The equivalent JavaScript Date object. |
| 71 | + */ |
| 72 | + getDateObject(): Date; |
| 73 | + /** |
| 74 | + * Retrieves the year of the Nepali date in the Nepali calendar. |
| 75 | + * |
| 76 | + * @returns {number} The full numeric value representing the year. Eg. 2080 |
| 77 | + */ |
12 | 78 | getYear(): number;
|
| 79 | + /** |
| 80 | + * Retrieves the year of the Nepali date in the English calendar. |
| 81 | + * |
| 82 | + * @returns {number} The full numeric value representing the year. Eg. 2009 |
| 83 | + */ |
| 84 | + getEnglishYear(): number; |
| 85 | + /** |
| 86 | + * Retrieves the month of the Nepali date in the Nepali calendar. |
| 87 | + * |
| 88 | + * @returns {number} The numeric value representing the month. 0 for Baishakh and 11 for Chaitra. |
| 89 | + */ |
13 | 90 | getMonth(): number;
|
| 91 | + /** |
| 92 | + * Retrieves the month of the Nepali date in the English calendar. |
| 93 | + * |
| 94 | + * @returns {number} The numeric value representing the month. 0 for January and 11 for December. |
| 95 | + */ |
| 96 | + getEnglishMonth(): number; |
| 97 | + /** |
| 98 | + * Retrieves the day of the month represented of Nepali date in Nepali calendar. |
| 99 | + * |
| 100 | + * @returns {number} The numeric value representing the day of the month. |
| 101 | + */ |
14 | 102 | getDate(): number;
|
| 103 | + /** |
| 104 | + * Retrieves the day of the month represented of Nepali date in English calendar. |
| 105 | + * |
| 106 | + * @returns {number} The numeric value representing the day of the month. |
| 107 | + */ |
| 108 | + getEnglishDate(): number; |
| 109 | + /** |
| 110 | + * Retrieves the day of the week represented by a numeric value. |
| 111 | + * |
| 112 | + * @returns The numeric value representing the day of the week. |
| 113 | + * 0: Sunday |
| 114 | + * 1: Monday |
| 115 | + * 2: Tuesday |
| 116 | + * 3: Wednesday |
| 117 | + * 4: Thursday |
| 118 | + * 5: Friday |
| 119 | + * 6: Saturday |
| 120 | + */ |
15 | 121 | getDay(): number;
|
| 122 | + /** |
| 123 | + * Retrieves the hour value of the Nepali date. |
| 124 | + * |
| 125 | + * @returns {number} The numeric value representing the hour. |
| 126 | + */ |
16 | 127 | getHours(): number;
|
| 128 | + /** |
| 129 | + * Retrieves the minute value of the Nepali date. |
| 130 | + * |
| 131 | + * @returns {number} The numeric value representing the minute. |
| 132 | + */ |
17 | 133 | getMinutes(): number;
|
| 134 | + /** |
| 135 | + * Retrieves the second value of the Nepali date. |
| 136 | + * |
| 137 | + * @returns {number} The numeric value representing the second. |
| 138 | + */ |
18 | 139 | getSeconds(): number;
|
| 140 | + /** |
| 141 | + * Retrieves the millisecond value of the Nepali date. |
| 142 | + * |
| 143 | + * @returns {number} The numeric value representing the millisecond. |
| 144 | + */ |
19 | 145 | getMilliseconds(): number;
|
| 146 | + /** |
| 147 | + * Retrieves the unix timestamp (in milliseconds) of the Nepali date. |
| 148 | + * |
| 149 | + * @returns {number} The numeric value representing the time in milliseconds. |
| 150 | + */ |
20 | 151 | getTime(): number;
|
| 152 | + /** |
| 153 | + * Sets the day on the current date and time |
| 154 | + * |
| 155 | + * @param {number} year - The numeric value representing the year. |
| 156 | + * @throws {ValidationError} if year is out of range |
| 157 | + */ |
21 | 158 | setYear(year: number): void;
|
| 159 | + /** |
| 160 | + * Sets the day on the current date and time |
| 161 | + * |
| 162 | + * @param {number} month - The numeric value representing the month. |
| 163 | + * @throws {ValidationError} if month is out of range |
| 164 | + */ |
22 | 165 | setMonth(month: number): void;
|
| 166 | + /** |
| 167 | + * Sets the day on the current date and time |
| 168 | + * |
| 169 | + * @param {number} day - The numeric value representing the day. |
| 170 | + * @throws {ValidationError} if day is out of range |
| 171 | + */ |
23 | 172 | setDate(day: number): void;
|
24 |
| - set(year: number, month: number, date: number): void; |
| 173 | + /** |
| 174 | + * Sets hour on the current date and time |
| 175 | + * |
| 176 | + * @param hour Hour to set |
| 177 | + * @throws {ValidationError} if hour is out of range |
| 178 | + */ |
| 179 | + setHours(hour: number): void; |
| 180 | + /** |
| 181 | + * Sets minute on the current date and time |
| 182 | + * |
| 183 | + * @param minute Minute to set |
| 184 | + * @throws {ValidationError} if minute is out of range |
| 185 | + */ |
| 186 | + setMinutes(minute: number): void; |
| 187 | + /** |
| 188 | + * Sets second on the current date and time |
| 189 | + * |
| 190 | + * @param second Second to set |
| 191 | + * @throws {ValidationError} if second is out of range |
| 192 | + */ |
| 193 | + setSeconds(second: number): void; |
| 194 | + /** |
| 195 | + * Sets milliseconds on the current date and time |
| 196 | + * |
| 197 | + * @param ms Milliseconds to set |
| 198 | + * @throws {ValidationError} if milliseconds is out of range |
| 199 | + */ |
| 200 | + setMilliseconds(ms: number): void; |
| 201 | + /** |
| 202 | + * Sets time on the object. |
| 203 | + * |
| 204 | + * @param time Time to set (timestamp) |
| 205 | + */ |
| 206 | + setTime(time: number): void; |
| 207 | + /** |
| 208 | + * Sets the Nepali date and time values. |
| 209 | + * |
| 210 | + * @param {number} year - The numeric value representing the year. |
| 211 | + * @param {number} month - The numeric value representing the month. |
| 212 | + * @param {number} date - The numeric value representing the day. |
| 213 | + * @param {number} [hour=0] - The numeric value representing the hour. |
| 214 | + * @param {number} [minute=0] - The numeric value representing the minute. |
| 215 | + * @param {number} [second=0] - The numeric value representing the second. |
| 216 | + * @param {number} [ms=0] - The numeric value representing the millisecond. |
| 217 | + */ |
| 218 | + set(year: number, month: number, date: number, hour: number, minute: number, second: number, ms: number): void; |
| 219 | + /** |
| 220 | + * Returns a string representation (in English) of the NepaliDate object in the specified format. |
| 221 | + * |
| 222 | + * @param {string} formatStr - The format string specifying the desired format. |
| 223 | + * @returns {string} The formatted Nepali date string. |
| 224 | + */ |
25 | 225 | format(formatStr: string): string;
|
| 226 | + /** |
| 227 | + * Returns a string representation in the Nepali (Devanagari) of the NepaliDate object in the specified format. |
| 228 | + * @param formatStr The format string for the desired output. |
| 229 | + * @returns {string} A string representation of the NepaliDate object in the specified format. |
| 230 | + */ |
| 231 | + formatNepali(formatStr: string): string; |
| 232 | + /** |
| 233 | + * Returns a string representation of the NepaliDate object. |
| 234 | + * |
| 235 | + * @returns {string} The string representation of the Nepali date. |
| 236 | + */ |
26 | 237 | toString(): string;
|
| 238 | + /** |
| 239 | + * Creates a new instance of NepaliDate from an English calendar parameters. |
| 240 | + * |
| 241 | + * @param year - The year in English calendar format. |
| 242 | + * @param month0 - The month (0-11) in English calendar format. |
| 243 | + * @param date - The day of the month in English calendar format. |
| 244 | + * @param hour - The hour (0-23) in English calendar format. Default is 0. |
| 245 | + * @param minute - The minute (0-59) in English calendar format. Default is 0. |
| 246 | + * @param second - The second (0-59) in English calendar format. Default is 0. |
| 247 | + * @param ms - The millisecond (0-999) in English calendar format. Default is 0. |
| 248 | + * @returns A new instance of NepaliDate corresponding to the provided English date. |
| 249 | + */ |
| 250 | + static fromEnglishDate(year: number, month0: number, date: number, hour?: number, minute?: number, second?: number, ms?: number): NepaliDate; |
27 | 251 | }
|
28 | 252 | export default NepaliDate;
|
0 commit comments