Skip to content

Commit 0aae3d8

Browse files
authored
Merge pull request #36 from sugat009/release-1.0.0
Release v1.0.0
2 parents a03cdf1 + 9a2e65b commit 0aae3d8

25 files changed

+3802
-591
lines changed

.github/SECURITY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ We provide security updates and support for the latest stable release of the 'no
88

99
| Version | Supported |
1010
| ------- | ------------------ |
11-
| 0.1.0 | :white_check_mark: |
12-
<!-- | < 0.0.0 | :x: | -->
11+
| 1.0.0 | :white_check_mark: |
12+
| 0.1.0 | :x: |
1313

1414
## Reporting a Vulnerability
1515

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ cjs
44

55
yarn-error.log
66
.log/
7-
coverage
7+
coverage
8+
9+
# jetbrains
10+
.idea/

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CHANGELOG
22

3-
## main
3+
## v1.0.0
44

55
- Added dateConverter module.
66
- Added time/timezone support in NepaliDate.

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ const [npYear, npMonth, npDay] = dateConverter.englishToNepali(2023, 5, 27);
204204
const [enYear, enMonth, enDay] = dateConverter.nepaliToEnglish(2080, 2, 15);
205205
```
206206

207+
## Acknowledgements
208+
209+
This project was inspired by [nepali-date](https://github.com/sharingapples/nepali-date). We would like to express our gratitude to their team for their excellent work and ideas, which served as a motivation for this project.
210+
207211
## Contribution
208212

209-
We appreciate feedback and contribution to this package. To get started please see our [contribution guide](CONTRIBUTING.md).
213+
We appreciate feedback and contribution to this package. To get started please see our [contribution guide](CONTRIBUTING.md).

dist/NepaliDate.d.ts

Lines changed: 228 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,252 @@
1+
/**
2+
* Represents a Nepali calendar date.
3+
*/
14
declare class NepaliDate {
25
timestamp: Date;
36
year: number;
7+
yearEn: number;
48
month: number;
9+
monthEn: number;
510
day: number;
11+
dayEn: number;
12+
hour: number;
13+
minute: number;
14+
weekDay: number;
615
static minimum: () => Date;
716
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+
*/
857
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+
*/
1278
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+
*/
1390
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+
*/
14102
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+
*/
15121
getDay(): number;
122+
/**
123+
* Retrieves the hour value of the Nepali date.
124+
*
125+
* @returns {number} The numeric value representing the hour.
126+
*/
16127
getHours(): number;
128+
/**
129+
* Retrieves the minute value of the Nepali date.
130+
*
131+
* @returns {number} The numeric value representing the minute.
132+
*/
17133
getMinutes(): number;
134+
/**
135+
* Retrieves the second value of the Nepali date.
136+
*
137+
* @returns {number} The numeric value representing the second.
138+
*/
18139
getSeconds(): number;
140+
/**
141+
* Retrieves the millisecond value of the Nepali date.
142+
*
143+
* @returns {number} The numeric value representing the millisecond.
144+
*/
19145
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+
*/
20151
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+
*/
21158
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+
*/
22165
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+
*/
23172
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+
*/
25225
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+
*/
26237
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;
27251
}
28252
export default NepaliDate;

dist/config.d.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

dist/constants.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export declare const UTC_OFFSET_IN_MS = 20700000;
2+
export declare const OLD_UTC_OFFSET_IN_MS = 19800000;
3+
export declare const TIMEZONE_TRANSITION_TIMESTAMP = 504901800000;
4+
export declare const TIMEZONE_TRANSITION_DATE_REFERENCE: Date;
5+
export declare const MONTHS_EN: string[];
6+
export declare const MONTHS_SHORT_EN: string[];
7+
export declare const MONTHS_NP: string[];
8+
export declare const MONTHS_SHORT_NP: string[];
9+
export declare const NUM_NP: string[];
10+
export declare const WEEKDAYS_SHORT_EN: string[];
11+
export declare const WEEKDAYS_LONG_EN: string[];
12+
export declare const WEEKDAYS_SHORT_NP: string[];
13+
export declare const WEEKDAYS_LONG_NP: string[];

0 commit comments

Comments
 (0)