@remotemerge/nepali-date-converter 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) Madan Sapkota
3
+ Copyright (c) 2026 Madan Sapkota
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,184 +1,474 @@
1
1
  # 📅 Nepali Date Converter
2
2
 
3
- [![Package](https://img.shields.io/npm/v/@remotemerge/nepali-date-converter?logo=npm)](https://www.npmjs.com/package/@remotemerge/nepali-date-converter)
4
- [![Build](https://img.shields.io/github/workflow/status/remotemerge/nepali-date-converter/Publish?logo=github)](README.md)
5
- [![Downloads](https://img.shields.io/npm/dt/@remotemerge/nepali-date-converter?logo=spreadshirt)](https://www.npmjs.com/package/@remotemerge/nepali-date-converter)
6
- [![Size](https://img.shields.io/bundlephobia/minzip/@remotemerge/nepali-date-converter?logo=ipfs)](https://bundlephobia.com/result?p=@remotemerge/nepali-date-converter)
7
- [![License](https://img.shields.io/npm/l/@remotemerge/nepali-date-converter?logo=opensourceinitiative)](LICENSE)
3
+ [![Package](https://img.shields.io/npm/v/@remotemerge/nepali-date-converter?logo=npm&logoColor=fff)](https://www.npmjs.com/package/@remotemerge/nepali-date-converter)
4
+ [![Build](https://img.shields.io/github/actions/workflow/status/remotemerge/nepali-date-converter/test.yml?logo=github-actions&logoColor=fff&label=build)](https://github.com/remotemerge/nepali-date-converter/actions/workflows/test.yml)
5
+ [![Tests](https://img.shields.io/github/actions/workflow/status/remotemerge/nepali-date-converter/test.yml?logo=jest&logoColor=fff&label=tests)](https://github.com/remotemerge/nepali-date-converter/actions/workflows/test.yml)
6
+ [![Downloads](https://img.shields.io/npm/dt/@remotemerge/nepali-date-converter?logo=icloud&logoColor=fff)](https://www.npmjs.com/package/@remotemerge/nepali-date-converter)
7
+ [![Size](https://img.shields.io/bundlephobia/minzip/@remotemerge/nepali-date-converter?logo=nodedotjs&logoColor=fff&label=size)](https://bundlephobia.com/package/@remotemerge/nepali-date-converter)
8
+ [![License](https://img.shields.io/github/license/remotemerge/nepali-date-converter?logo=opensourceinitiative&logoColor=fff)](LICENSE)
8
9
 
9
- **Nepali Date Converter** is a lightweight, high-performance JavaScript library designed to simplify date conversions between the **Bikram Sambat (BS)** and **Gregorian (AD)** calendars. Whether you're building applications for Nepali users or working with historical data, NDC provides accurate and efficient date conversion for **1975 BS to 2099 BS** (1918 AD to 2043 AD). Perfect for developers working with Nepali calendars, festivals, or events.
10
+ > **Fast, accurate, and lightweight JavaScript library for converting dates between Nepali Bikram Sambat (BS) and Gregorian/English (AD) calendars.**
11
+
12
+ **Nepali Date Converter (NDC)** is a modern, production-ready JavaScript library designed for seamless date conversions between the **Bikram Sambat (BS)** calendar used in Nepal and the **Gregorian (AD)** calendar used internationally. Whether you're building Nepali calendar applications, event management systems, government portals, or localization features, NDC provides **100% accurate** date conversions for the range **1975 BS to 2099 BS** (1918 AD to 2043 AD).
13
+
14
+ Built with **TypeScript** and powered by **Bun**, this library is optimized for performance with a tiny bundle size (~5 KiB minified), making it perfect for web applications, Node.js services, mobile apps, and server-side rendering.
10
15
 
11
16
  ---
12
17
 
13
18
  ## ✨ Features
14
19
 
15
- - **Accurate Date Conversion**: Convert dates between **BS (Bikram Sambat)** and **AD (Gregorian)** with 100% accuracy.
16
- - **Wide Date Range**: Supports conversion for **1975 BS to 2099 BS** (1918 AD to 2043 AD).
17
- - **Lightweight**: Just **7.3 KB** (plain) and **2.2 KB** (gzipped) — optimized for performance.
18
- - **TypeScript Support**: Built-in TypeScript types for a seamless development experience.
19
- - **Cross-Platform**: Works in **Node.js**, **browsers**, and bundlers like **Webpack**, **Rollup**, **Vite**, etc.
20
- - **Fast and Reliable**: Localized data and optimized code for lightning-fast results.
20
+ - 🎯 **Accurate Conversions**: 100% accurate date conversions between Bikram Sambat (BS) and Gregorian (AD) calendars
21
+ - 📆 **Wide Date Range**: Supports **1975 BS to 2099 BS** (April 13, 1918 AD to April 13, 2043 AD)
22
+ - **Lightweight & Fast**: Only **~5 KiB** minified and **~1.8 KiB** gzipped — optimized for fast page loads
23
+ - 🇳🇵 **Nepali Unicode Support**: Accepts Nepali numerals (०-९) and multiple date format separators
24
+ - 🔒 **TypeScript Native**: Full TypeScript support with built-in type definitions and autocompletion
25
+ - 🌐 **Universal Compatibility**: Works in Node.js (v20+), modern browsers, and all major bundlers (Vite, Webpack, Rollup, esbuild)
26
+ - 🚀 **Modern Tooling**: Built with Bun, Vite, Oxlint, and Oxfmt for fast development and builds
27
+ - 🧪 **Well-Tested**: Comprehensive test suite validating every date in the supported range
28
+ - 🐳 **Docker Ready**: Includes Docker configuration for consistent cross-platform development
29
+ - 📦 **Zero Dependencies**: Minimal runtime footprint with only essential dependencies
21
30
 
22
31
  ---
23
32
 
24
- ## 🚀 Installation
33
+ ## 📦 Installation
25
34
 
26
- Install the package via **npm** or **Yarn**:
35
+ ### npm
27
36
 
28
37
  ```bash
29
38
  npm install @remotemerge/nepali-date-converter
30
39
  ```
31
40
 
32
- or
41
+ ### Yarn
33
42
 
34
43
  ```bash
35
44
  yarn add @remotemerge/nepali-date-converter
36
45
  ```
37
46
 
47
+ ### pnpm
48
+
49
+ ```bash
50
+ pnpm add @remotemerge/nepali-date-converter
51
+ ```
52
+
53
+ ### Bun
54
+
55
+ ```bash
56
+ bun add @remotemerge/nepali-date-converter
57
+ ```
58
+
38
59
  ---
39
60
 
40
- ## 📖 Quick Start
41
- To get started with the Nepali Date Converter, follow the simple examples below. You can convert dates from **BS to AD** or **AD to BS** with just a few lines of code.
61
+ ## 🚀 Quick Start
62
+
63
+ The Nepali Date Converter library is straightforward to use. Import the `DateConverter` class, instantiate it with a date string in `YYYY-MM-DD` format, and call either `.toAd()` to convert from Bikram Sambat to Gregorian, or `.toBs()` to convert from Gregorian to Bikram Sambat.
42
64
 
43
- ### Importing the Library
65
+ ### ES Modules (Recommended)
44
66
 
45
- #### ES Modules (Recommended for Modern JavaScript/TypeScript Projects)
46
67
  ```javascript
47
- import DateConverter from '@remotemerge/nepali-date-converter';
68
+ import DateConverter from "@remotemerge/nepali-date-converter";
69
+
70
+ // Convert BS to AD
71
+ const adDate = new DateConverter("2080-01-15").toAd();
72
+ console.log(adDate);
73
+ // Output: { year: 2023, month: 4, date: 28, day: 'Friday' }
74
+
75
+ // Convert AD to BS
76
+ const bsDate = new DateConverter("2023-04-28").toBs();
77
+ console.log(bsDate);
78
+ // Output: { year: 2080, month: 1, date: 15, day: 'Friday' }
48
79
  ```
49
80
 
50
- #### CommonJS (For Node.js or Legacy Projects)
81
+ ### CommonJS
82
+
51
83
  ```javascript
52
- const DateConverter = require('@remotemerge/nepali-date-converter');
84
+ const DateConverter = require("@remotemerge/nepali-date-converter");
85
+
86
+ const converted = new DateConverter("2080-01-15").toAd();
87
+ console.log(converted);
88
+ ```
89
+
90
+ ### Browser (CDN)
91
+
92
+ ```html
93
+
94
+ <script src="https://cdn.jsdelivr.net/npm/@remotemerge/nepali-date-converter@1/dist/ndc-browser.js"></script>
95
+ <script>
96
+ const converted = new DateConverter("2080-01-15").toAd();
97
+ console.log(converted);
98
+ </script>
53
99
  ```
54
100
 
55
101
  ---
56
102
 
57
- ### Converting BS to AD
103
+ ## 📖 API Reference
58
104
 
59
- Convert a **Bikram Sambat (BS)** date to a **Gregorian (AD)** date. Simply pass the BS date in `YYYY-MM-DD` format to the `DateConverter` and call the `.toAd()` method.
105
+ The `DateConverter` class provides a simple, intuitive API for converting dates between the Nepali Bikram Sambat calendar and the Gregorian calendar. All methods return plain JavaScript objects with full type safety when using TypeScript.
60
106
 
61
- ```javascript
62
- // Convert BS date '2079-10-17' to AD
63
- const converted = new DateConverter('2079-10-17').toAd();
64
- console.log(converted);
65
- ```
107
+ ### Constructor
66
108
 
67
- **Output**:
68
109
  ```text
69
- { year: 2023, month: 1, date: 30, day: 'Monday' }
110
+ new DateConverter(date: string)
70
111
  ```
71
112
 
72
- - **Input Format**: `YYYY-MM-DD` (Bikram Sambat date).
73
- - **Output**: An object containing the converted Gregorian date (`year`, `month`, `date`) and the day of the week (`day`).
74
-
75
- ---
113
+ **Parameters:**
76
114
 
77
- ### Converting AD to BS
115
+ - `date` (string): Date string in `YYYY-MM-DD` format. Accepts both BS (Nepali) and AD (Gregorian) dates.
116
+ - Supports multiple separators: `-`, `/`, `.`, `,`, `|`
117
+ - Supports Nepali Unicode numerals (e.g., `२०८०-०१-१५` for 2080-01-15)
118
+ - Automatically detects whether the input is BS or AD based on the date range
78
119
 
79
- Convert a **Gregorian (AD)** date to a **Bikram Sambat (BS)** date. Pass the AD date in `YYYY-MM-DD` format to the `DateConverter` and call the `.toBs()` method.
120
+ **Examples:**
80
121
 
81
122
  ```javascript
82
- // Convert AD date '2023-01-30' to BS
83
- const converted = new DateConverter('2023-01-30').toBs();
84
- console.log(converted);
123
+ new DateConverter("2080-01-15"); // Standard BS format with hyphen
124
+ new DateConverter("2080/01/15"); // Slash separator
125
+ new DateConverter("२०८०-०१-१५"); // Nepali numerals (Devanagari script)
85
126
  ```
86
127
 
87
- **Output**:
88
- ```text
89
- { year: 2079, month: 10, date: 17, day: 'Monday' }
128
+ ### Methods
129
+
130
+ #### `.toAd()`
131
+
132
+ Converts a Bikram Sambat (BS) date to its equivalent Gregorian (AD) date. This method is essential for displaying Nepali dates in international format for web applications, mobile apps, and data processing systems.
133
+
134
+ **Returns:**
135
+
136
+ ```typescript
137
+ {
138
+ year: number; // AD year (e.g., 2023)
139
+ month: number; // AD month (1-12)
140
+ date: number; // AD day of month (1-31)
141
+ day: string; // Day name (e.g., "Monday", "Tuesday")
142
+ }
90
143
  ```
91
144
 
92
- - **Input Format**: `YYYY-MM-DD` (Gregorian date).
93
- - **Output**: An object containing the converted Bikram Sambat date (`year`, `month`, `date`) and the day of the week (`day`).
145
+ **Example:**
94
146
 
95
- ---
147
+ ```javascript
148
+ // Convert Nepali date to English/Gregorian date
149
+ const result = new DateConverter("2080-01-15").toAd();
150
+ // { year: 2023, month: 4, date: 28, day: 'Friday' }
151
+ ```
96
152
 
97
- ### Using the Library in the Browser (CDN)
153
+ #### `.toBs()`
98
154
 
99
- You can also use the library directly in your HTML files via **jsDelivr CDN**. This is ideal for quick prototyping or projects without a build system.
155
+ Converts a Gregorian (AD) date to its equivalent Bikram Sambat (BS) date. Use this method when you need to display dates in Nepali calendar format for local audiences, festivals, and government systems in Nepal.
100
156
 
101
- ```html
102
- <script src="https://cdn.jsdelivr.net/npm/@remotemerge/nepali-date-converter@1/dist/ndc-browser.js"></script>
103
- <script>
104
- // Convert BS date '2079-10-17' to AD
105
- const converted = new DateConverter('2079-10-17').toAd();
106
- console.log(converted);
107
- </script>
157
+ **Returns:**
158
+
159
+ ```typescript
160
+ {
161
+ year: number; // BS year (e.g., 2080)
162
+ month: number; // BS month (1-12)
163
+ date: number; // BS day of month (1-32, varies by month)
164
+ day: string; // Day name (e.g., "Monday", "Tuesday")
165
+ }
166
+ ```
167
+
168
+ **Example:**
169
+
170
+ ```javascript
171
+ // Convert English/Gregorian date to Nepali date
172
+ const result = new DateConverter("2023-04-28").toBs();
173
+ // { year: 2080, month: 1, date: 15, day: 'Friday' }
108
174
  ```
109
175
 
110
176
  ---
111
177
 
112
- ### Example Use Cases
178
+ ## 💡 Usage Examples
113
179
 
114
- 1. **Event Planning**: Convert Nepali festival dates to Gregorian dates for international users.
115
- 2. **Historical Data**: Work with historical records that use the Bikram Sambat calendar.
116
- 3. **Localization**: Display dates in the Nepali calendar for Nepali-speaking users.
180
+ The Nepali Date Converter library is versatile and can be used in various real-world scenarios. Below are practical examples demonstrating how to integrate the library into your applications, from festival date conversions to historical data processing and multilingual support.
117
181
 
118
- ---
182
+ ### Basic Conversions
183
+
184
+ ```javascript
185
+ import DateConverter from "@remotemerge/nepali-date-converter";
119
186
 
120
- ### Advanced Usage
187
+ // Festival date conversion - Dashain, Tihar, and other Nepali festivals
188
+ const dashainDate = new DateConverter("2080-07-01").toAd();
189
+ console.log(`Dashain 2080 starts: ${dashainDate.month}/${dashainDate.date}/${dashainDate.year}`);
121
190
 
122
- #### Handling Invalid Dates
123
- If an invalid date is provided, the library will throw an error. Always ensure the input date is within the supported range (**1975 BS to 2099 BS** or **1918 AD to 2043 AD**).
191
+ // Historical record conversion - Nepal history, government documents
192
+ const historicalDate = new DateConverter("1950-01-01").toBs();
193
+ console.log(`January 1, 1950 AD = ${historicalDate.year}-${historicalDate.month}-${historicalDate.date} BS`);
194
+
195
+ // Birthday and anniversary conversions
196
+ const birthdayBS = new DateConverter("2024-06-15").toBs();
197
+ console.log(`Your Nepali birthday: ${birthdayBS.year}/${birthdayBS.month}/${birthdayBS.date}`);
198
+ ```
199
+
200
+ ### Error Handling
124
201
 
125
202
  ```javascript
126
203
  try {
127
- const converted = new DateConverter('2100-01-01').toAd(); // Invalid date
204
+ const converted = new DateConverter("2100-01-01").toAd();
128
205
  } catch (error) {
129
- console.error(error.message); // "The input date is out of supported range."
206
+ console.error(error.message);
207
+ // "The input date is out of supported range."
130
208
  }
131
209
  ```
132
210
 
133
- #### Working with TypeScript
134
- The library includes built-in TypeScript support, so you get full type checking and autocompletion in your editor.
211
+ ### TypeScript Usage
135
212
 
136
213
  ```typescript
137
- import DateConverter from '@remotemerge/nepali-date-converter';
214
+ import DateConverter from "@remotemerge/nepali-date-converter";
215
+
216
+ const converter = new DateConverter("2080-01-15");
217
+ const result = converter.toAd();
138
218
 
139
- const converted = new DateConverter('2079-10-17').toAd();
140
- console.log(converted.year); // TypeScript knows this is a number
219
+ // Full type safety and autocompletion
220
+ console.log(result.year); // number
221
+ console.log(result.month); // number
222
+ console.log(result.date); // number
223
+ console.log(result.day); // string
224
+ ```
225
+
226
+ ### Multiple Date Formats
227
+
228
+ ```javascript
229
+ // All of these work identically:
230
+ new DateConverter("2080-01-15").toAd(); // Hyphen
231
+ new DateConverter("2080/01/15").toAd(); // Slash
232
+ new DateConverter("2080.01.15").toAd(); // Dot
233
+ new DateConverter("2080,01,15").toAd(); // Comma
234
+ new DateConverter("2080|01|15").toAd(); // Pipe
235
+ new DateConverter("२०८०-०१-१५").toAd(); // Nepali numerals
141
236
  ```
142
237
 
143
238
  ---
144
239
 
145
- ## 📊 Why Use Nepali Date Converter?
240
+ ## 🇳🇵 About Bikram Sambat Calendar
146
241
 
147
- - **Production-Ready**: Tested and verified for 100% accuracy across the supported date range.
148
- - **Developer-Friendly**: Simple API, TypeScript support, and detailed documentation.
149
- - **Lightweight**: Minimal bundle size for fast loading and performance.
150
- - **Open Source**: MIT licensed — free to use, modify, and distribute.
242
+ **Bikram Sambat (BS)**, also known as **Bikrami calendar** or **Nepali calendar**, is the official calendar of Nepal and is widely used throughout the country for government, business, and cultural purposes. Named after the legendary Indian king Vikramaditya, this lunar calendar system is approximately 56.7 years ahead of the Gregorian calendar.
243
+
244
+ ### Key Facts About Bikram Sambat
245
+
246
+ - **Official Calendar of Nepal**: Used by the Government of Nepal for fiscal years, official documents, and public holidays
247
+ - **Lunar-Based System**: Months are based on lunar cycles, with each month having 29–32 days
248
+ - **New Year**: Falls in mid-April (Baishakh 1), marking the beginning of spring in Nepal
249
+ - **Cultural Significance**: Determines dates for major festivals like Dashain, Tihar, Holi, and Teej
250
+ - **Historical Origins**: Dates back to 57 BC, making it one of the oldest calendar systems still in use
251
+ - **Geographic Usage**: Primarily used in Nepal and parts of India (especially in northern states)
252
+
253
+ The Nepali Date Converter library handles the complex mathematics required to convert between these two calendar systems accurately, accounting for varying month lengths and leap years in the Bikram Sambat system.
151
254
 
152
255
  ---
153
256
 
154
- ## 🔧 API Reference
257
+ ## 🛠️ Development
155
258
 
156
- ### `DateConverter(date: string)`
259
+ This section provides a comprehensive guide for developers who want to contribute to the Nepali Date Converter project or build it locally. The project uses modern JavaScript tooling, including Bun for package management and testing, Vite for building, and Oxlint/Oxfmt for code quality.
157
260
 
158
- - **`date`**: A string in `YYYY-MM-DD` format (either BS or AD).
261
+ ### Prerequisites
159
262
 
160
- ### Methods
263
+ - **Bun** >= 1.3.11 (required for development and building)
264
+ - Node.js >= 20 (for consuming the package)
161
265
 
162
- - **`.toAd()`**: Converts a BS date to an AD date.
163
- - Returns: `{ year: number, month: number, date: number, day: string }`
266
+ ### Setup
164
267
 
165
- - **`.toBs()`**: Converts an AD date to a BS date.
166
- - Returns: `{ year: number, month: number, date: number, day: string }`
268
+ ```bash
269
+ # Navigate to the source directory
270
+ cd html
271
+
272
+ # Install dependencies
273
+ bun install
274
+ ```
275
+
276
+ ### Available Scripts
277
+
278
+ | Command | Description |
279
+ |--------------------|---------------------------------------------------------------------|
280
+ | `bun run dev` | Start development server with hot reload (localhost:3000) |
281
+ | `bun run build` | Build production bundles (ESM, CJS, IIFE) + TypeScript declarations |
282
+ | `bun run test` | Run test suite using Bun's native test runner |
283
+ | `bun run lint` | Run Oxlint and Oxfmt checks |
284
+ | `bun run lint:fix` | Auto-fix linting and formatting issues |
285
+
286
+ ### Project Structure
287
+
288
+ ```text
289
+ html/
290
+ ├── src/
291
+ │ ├── index.ts # Main DateConverter class
292
+ │ └── years.ts # Nepali calendar data (1975-2099 BS)
293
+ ├── __tests__/
294
+ │ ├── bs.spec.ts # AD to BS conversion tests
295
+ │ ├── ad.spec.ts # BS to AD conversion tests
296
+ │ └── data.json # Test data fixtures
297
+ ├── dist/ # Generated build output
298
+ │ ├── ndc.js # ESM bundle
299
+ │ ├── ndc-node.js # CommonJS bundle
300
+ │ ├── ndc-browser.js # IIFE bundle (browser-ready)
301
+ │ └── *.d.ts # TypeScript declarations
302
+ ├── scripts/
303
+ │ └── post-build.ts # Post-build package.json generator
304
+ ├── package.json
305
+ ├── tsconfig.json
306
+ ├── vite.config.ts
307
+ ├── oxlint.config.ts
308
+ └── oxfmt.config.ts
309
+ ```
310
+
311
+ ### Building
312
+
313
+ ```bash
314
+ cd html
315
+ bun run build
316
+ ```
317
+
318
+ This generates:
319
+
320
+ - **ndc.js** - ES Module (for modern bundlers)
321
+ - **ndc-node.js** - CommonJS (for Node.js)
322
+ - **ndc-browser.js** - IIFE (for direct browser usage)
323
+ - **TypeScript declaration files** (.d.ts)
324
+ - **Packaged dist/** - Ready for npm distribution
325
+
326
+ ### Testing
327
+
328
+ ```bash
329
+ # Run all tests
330
+ bun run test
331
+
332
+ # Run specific test file
333
+ bun test __tests__/bs.spec.ts
334
+ ```
335
+
336
+ Tests validate conversion accuracy across the entire supported date range using comprehensive fixtures.
337
+
338
+ ### Linting & Formatting
339
+
340
+ The project uses modern tooling:
341
+
342
+ - **Oxlint** - Fast Rust-based linter (ESLint replacement)
343
+ - **Oxfmt** - Code formatter
344
+
345
+ ```bash
346
+ # Check for issues
347
+ bun run lint
348
+
349
+ # Auto-fix issues
350
+ bun run lint:fix
351
+ ```
167
352
 
168
353
  ---
169
354
 
170
- ## 📜 License
355
+ ## 🐳 Docker Development
171
356
 
172
- This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for details.
357
+ For consistent development environments, the project includes Docker support:
358
+
359
+ ```bash
360
+ # Start development environment
361
+ bash start-docker.sh
362
+
363
+ # Or use the CLI wrapper
364
+ bash app-cli.sh
365
+ ```
366
+
367
+ The Docker setup:
368
+
369
+ - Uses Bun 1.3.11 base image
370
+ - Configures proper UID/GID mapping
371
+ - Runs development server on port 3000
372
+ - Maintains file ownership across host/container
173
373
 
174
374
  ---
175
375
 
176
- ## 🙌 Contributing
376
+ ## 📊 Bundle Analysis
177
377
 
178
- Contributions are welcome! If you find a bug or have a feature request, please open an issue on the [GitHub repository](https://github.com/remotemerge/nepali-date-converter).
378
+ | Format | File | Size (minified) | Size (gzipped) |
379
+ |--------|------------------|-----------------|----------------|
380
+ | ESM | `ndc.js` | ~5 KiB | ~1.8 KiB |
381
+ | CJS | `ndc-node.js` | ~5 KiB | ~1.8 KiB |
382
+ | IIFE | `ndc-browser.js` | ~5 KiB | ~1.8 KiB |
179
383
 
180
384
  ---
181
385
 
182
- ## 📄 Documentation
386
+ ## 🌟 Common Use Cases
387
+
388
+ The Nepali Date Converter library is widely used in various applications and systems. Here are some of the most common scenarios where developers integrate this library:
389
+
390
+ ### 🏛️ Government & Public Sector
391
+
392
+ - **Government Portals**: Converting official dates for documents, certificates, and public notices
393
+ - **Municipal Systems**: Local government applications for citizen services
394
+ - **Legal Documents**: Court dates, legal filings, and official records in Nepal
395
+
396
+ ### 🎉 Festival & Event Management
397
+
398
+ - **Festival Calendars**: Displaying dates for Dashain, Tihar, Holi, Teej, and other Nepali festivals
399
+ - **Event Planning**: Scheduling events that use both BS and AD dates
400
+ - **Cultural Applications**: Preserving and displaying Nepali cultural events
401
+
402
+ ### 💼 Business & Enterprise
403
+
404
+ - **Accounting Systems**: Nepali fiscal year calculations and financial reporting
405
+ - **Payroll Systems**: Employee salary calculations using BS dates
406
+ - **ERP Systems**: Enterprise resource planning for Nepali companies
407
+ - **HR Applications**: Leave management, attendance tracking with Nepali dates
408
+
409
+ ### 📱 Web & Mobile Applications
410
+
411
+ - **Calendar Apps**: Dual calendar displays showing both BS and AD dates
412
+ - **Date Pickers**: UI components for selecting Nepali dates
413
+ - **News Portals**: Displaying publication dates in both calendar systems
414
+ - **Social Media**: Timestamp conversions for Nepali audiences
415
+
416
+ ### 🎓 Education & Research
417
+
418
+ - **Academic Calendars**: School and university schedules in Nepal
419
+ - **Historical Research**: Converting historical dates for research papers
420
+ - **Data Analysis**: Processing datasets with mixed calendar systems
421
+
422
+ ### 🏥 Healthcare
423
+
424
+ - **Medical Records**: Patient records using Nepali dates
425
+ - **Appointment Systems**: Scheduling with BS date displays
426
+ - **Pharmacy Applications**: Medicine expiry date tracking
427
+
428
+ ---
429
+
430
+ ## 🤝 Contributing
431
+
432
+ We welcome contributions from the community! Whether you're fixing a bug, adding features, improving documentation, or reporting issues, your help makes this library better for everyone in the Nepali developer community. Below is a comprehensive guide to contributing to the Nepali Date Converter project.
433
+
434
+ ### Reporting Issues
435
+
436
+ - **Bug Reports**: Open an issue with clear steps to reproduce the behavior
437
+ - **Feature Requests**: Describe the use case and expected behavior in detail
438
+ - **Documentation Issues**: Suggest improvements or report outdated information
439
+
440
+ ### Code Contributions
441
+
442
+ 1. Fork the repository
443
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
444
+ 3. Make your changes
445
+ 4. Run tests: `bun run test`
446
+ 5. Run linter: `bun run lint:fix`
447
+ 6. Commit your changes (follow [Conventional Commits](https://www.conventionalcommits.org/))
448
+ 7. Push to your branch
449
+ 8. Open a Pull Request
450
+
451
+ ### Development Guidelines
452
+
453
+ - **TypeScript**: Write TypeScript with strict mode enabled for type safety
454
+ - **Testing**: Add comprehensive tests for all new functionality
455
+ - **Code Style**: Follow existing code patterns and conventions
456
+ - **Quality Checks**: Ensure `bun run lint` passes with no errors or warnings
457
+ - **Documentation**: Update documentation and examples when adding features
458
+
459
+ ---
460
+
461
+ ## 📄 License
462
+
463
+ This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for details.
464
+
465
+ ---
466
+
467
+ ## 🙏 Acknowledgments
468
+
469
+ - Calendar data sourced from official Nepali calendar specifications
470
+ - Built with modern tooling: [Bun](https://bun.sh/), [Vite](https://vitejs.dev/), and [Oxlint](https://oxc.rs/)
471
+
472
+ ---
183
473
 
184
- For detailed documentation and advanced usage, visit the [GitHub repository](https://github.com/remotemerge/nepali-date-converter).
474
+ **Made with ❤️ for the Nepali developer community**
package/ndc-browser.js CHANGED
@@ -1,2 +1 @@
1
- var DateConverter=function(){"use strict";var S=Object.defineProperty;var E=(h,i,c)=>i in h?S(h,i,{enumerable:!0,configurable:!0,writable:!0,value:c}):h[i]=c;var d=(h,i,c)=>E(h,typeof i!="symbol"?i+"":i,c);const i=Symbol.for("constructDateFrom");function c(r,e){return typeof r=="function"?r(e):r&&typeof r=="object"&&i in r?r[i](e):r instanceof Date?new r.constructor(e):new Date(e)}function D(r,e){return c(r,r)}function m(r,e,n){const a=D(r);return isNaN(e)?c(r,NaN):(e&&a.setDate(a.getDate()+e),a)}function l(r){const e=D(r),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+r-+n}function g(r,...e){const n=c.bind(null,e.find(a=>typeof a=="object"));return e.map(n)}function f(r,e){const n=D(r);return n.setHours(0,0,0,0),n}function p(r,e,n){const[a,o]=g(n==null?void 0:n.in,r,e),s=f(a),u=f(o),y=+s-l(s),Y=+u-l(u);return Math.round((y-Y)/864e5)}function w(r,e){const n=D(r);return n.setHours(23,59,59,999),n}function T(r,e,n){const a=+D(r),[o,s]=[+D(e.start),+D(e.end)].sort((u,y)=>u-y);return a>=o&&a<=s}const t=[];t[1975]=[31,31,32,32,31,30,30,29,30,29,30,30,365],t[1976]=[31,32,31,32,31,30,30,30,29,29,30,31,366],t[1977]=[30,32,31,32,31,31,29,30,30,29,29,31,365],t[1978]=[31,31,32,31,31,31,30,29,30,29,30,30,365],t[1979]=t[1975],t[1980]=t[1976],t[1981]=[31,31,31,32,31,31,29,30,30,29,29,31,365],t[1982]=t[1978],t[1983]=t[1975],t[1984]=t[1976],t[1985]=[31,31,31,32,31,31,29,30,30,29,30,30,365],t[1986]=t[1978],t[1987]=[31,32,31,32,31,30,30,29,30,29,30,30,365],t[1988]=t[1976],t[1989]=[31,31,31,32,31,31,30,29,30,29,30,30,365],t[1990]=t[1978],t[1991]=[31,32,31,32,31,30,30,30,29,29,30,30,365],t[1992]=[31,32,31,32,31,30,30,30,29,30,29,31,366],t[1993]=t[1989],t[1994]=t[1978],t[1995]=t[1991],t[1996]=t[1992],t[1997]=t[1978],t[1998]=[31,31,32,31,32,30,30,29,30,29,30,30,365],t[1999]=t[1976],t[2e3]=[30,32,31,32,31,30,30,30,29,30,29,31,365],t[2001]=t[1978],t[2002]=t[1975],t[2003]=t[1976],t[2004]=t[2e3],t[2005]=t[1978],t[2006]=t[1975],t[2007]=t[1976],t[2008]=t[1981],t[2009]=t[1978],t[2010]=t[1975],t[2011]=t[1976],t[2012]=t[1985],t[2013]=t[1978],t[2014]=t[1975],t[2015]=t[1976],t[2016]=t[1985],t[2017]=t[1978],t[2018]=t[1987],t[2019]=t[1992],t[2020]=t[1989],t[2021]=t[1978],t[2022]=t[1991],t[2023]=t[1992],t[2024]=t[1989],t[2025]=t[1978],t[2026]=t[1976],t[2027]=t[2e3],t[2028]=t[1978],t[2029]=t[1998],t[2030]=t[1976],t[2031]=t[2e3],t[2032]=t[1978],t[2033]=t[1975],t[2034]=t[1976],t[2035]=t[1977],t[2036]=t[1978],t[2037]=t[1975],t[2038]=t[1976],t[2039]=t[1985],t[2040]=t[1978],t[2041]=t[1975],t[2042]=t[1976],t[2043]=t[1985],t[2044]=t[1978],t[2045]=t[1987],t[2046]=t[1976],t[2047]=t[1989],t[2048]=t[1978],t[2049]=t[1991],t[2050]=t[1992],t[2051]=t[1989],t[2052]=t[1978],t[2053]=t[1991],t[2054]=t[1992],t[2055]=t[1978],t[2056]=t[1998],t[2057]=t[1976],t[2058]=t[2e3],t[2059]=t[1978],t[2060]=t[1975],t[2061]=t[1976],t[2062]=[30,32,31,32,31,31,29,30,29,30,29,31,365],t[2063]=t[1978],t[2064]=t[1975],t[2065]=t[1976],t[2066]=t[1981],t[2067]=t[1978],t[2068]=t[1975],t[2069]=t[1976],t[2070]=t[1985],t[2071]=t[1978],t[2072]=t[1987],t[2073]=t[1976],t[2074]=t[1989],t[2075]=t[1978],t[2076]=t[1991],t[2077]=t[1992],t[2078]=t[1989],t[2079]=t[1978],t[2080]=t[1991],t[2081]=t[1992],t[2082]=t[1989],t[2083]=t[1978],t[2084]=t[1976],t[2085]=t[2e3],t[2086]=t[1978],t[2087]=t[1975],t[2088]=t[1976],t[2089]=t[2e3],t[2090]=t[1978],t[2091]=t[1975],t[2092]=t[1976],t[2093]=t[1981],t[2094]=t[1978],t[2095]=t[1975],t[2096]=t[1976],t[2097]=t[1985],t[2098]=t[1978],t[2099]=t[1975];class M{constructor(e){d(this,"startDate",new Date("1918-04-13"));d(this,"endDate",new Date("2043-04-13"));d(this,"dateRangeError","The input date is out of supported range.");d(this,"inputYear");d(this,"inputMonth");d(this,"inputDate");const[n,a,o]=this.parseDateString(e);this.inputYear=n,this.inputMonth=a,this.inputDate=o}parseDateString(e){const n=this.numToEn(e).replace(/[./|,]/g,"-").trim(),[a,o,s]=n.split("-").map(Number);return[a,o,s]}numToEn(e){const n=["०","१","२","३","४","५","६","७","८","९"];return e.replace(/[०१२३४५६७८९]/g,a=>n.indexOf(a).toString())}numToDay(e){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][e]}getAdDate(e,n,a){let o=0;for(let s=1975;s<e;s++)o+=t[s][12];for(let s=0;s<n-1;s++)o+=t[e][s];return o+=a-1,m(this.startDate,o)}getBsDate(e){const n=new Date(e);let a=p(n,this.startDate);for(const o in t){const s=t[o][12];if(a>=s){a-=s;continue}for(let u=0;u<12;u++){const y=t[o][u];if(a>=y){a-=y;continue}return{year:Number(o),month:u+1,date:a+1}}}throw new Error(this.dateRangeError)}toAd(){if(this.inputYear<1975||this.inputYear>2099)throw new Error(this.dateRangeError);const e=this.getAdDate(this.inputYear,this.inputMonth,this.inputDate),n=this.numToDay(e.getDay());return{year:e.getFullYear(),month:e.getMonth()+1,date:e.getDate(),day:n}}toBs(){const e=`${this.inputYear}-${this.inputMonth}-${this.inputDate}`,n=new Date(e);if(!T(n,{start:f(this.startDate),end:w(this.endDate)}))throw new Error(this.dateRangeError);const a=this.getBsDate(e),o=this.numToDay(n.getDay());return{...a,day:o}}}return M}();
2
- //# sourceMappingURL=ndc-browser.js.map
1
+ var DateConverter=(function(){function e(e,t){let n=new Date(e.getTime());return n.setUTCDate(n.getUTCDate()+t),n}function t(e,t){let n=Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),r=Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate());return Math.round((n-r)/(1440*60*1e3))}function n(e){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))}function r(e){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),23,59,59,999))}function i(e,t){let n=e.getTime();return n>=t.start.getTime()&&n<=t.end.getTime()}var a=[];return a[1975]=[31,31,32,32,31,30,30,29,30,29,30,30,365],a[1976]=[31,32,31,32,31,30,30,30,29,29,30,31,366],a[1977]=[30,32,31,32,31,31,29,30,30,29,29,31,365],a[1978]=[31,31,32,31,31,31,30,29,30,29,30,30,365],a[1979]=a[1975],a[1980]=a[1976],a[1981]=[31,31,31,32,31,31,29,30,30,29,29,31,365],a[1982]=a[1978],a[1983]=a[1975],a[1984]=a[1976],a[1985]=[31,31,31,32,31,31,29,30,30,29,30,30,365],a[1986]=a[1978],a[1987]=[31,32,31,32,31,30,30,29,30,29,30,30,365],a[1988]=a[1976],a[1989]=[31,31,31,32,31,31,30,29,30,29,30,30,365],a[1990]=a[1978],a[1991]=[31,32,31,32,31,30,30,30,29,29,30,30,365],a[1992]=[31,32,31,32,31,30,30,30,29,30,29,31,366],a[1993]=a[1989],a[1994]=a[1978],a[1995]=a[1991],a[1996]=a[1992],a[1997]=a[1978],a[1998]=[31,31,32,31,32,30,30,29,30,29,30,30,365],a[1999]=a[1976],a[2e3]=[30,32,31,32,31,30,30,30,29,30,29,31,365],a[2001]=a[1978],a[2002]=a[1975],a[2003]=a[1976],a[2004]=a[2e3],a[2005]=a[1978],a[2006]=a[1975],a[2007]=a[1976],a[2008]=a[1981],a[2009]=a[1978],a[2010]=a[1975],a[2011]=a[1976],a[2012]=a[1985],a[2013]=a[1978],a[2014]=a[1975],a[2015]=a[1976],a[2016]=a[1985],a[2017]=a[1978],a[2018]=a[1987],a[2019]=a[1992],a[2020]=a[1989],a[2021]=a[1978],a[2022]=a[1991],a[2023]=a[1992],a[2024]=a[1989],a[2025]=a[1978],a[2026]=a[1976],a[2027]=a[2e3],a[2028]=a[1978],a[2029]=a[1998],a[2030]=a[1976],a[2031]=a[2e3],a[2032]=a[1978],a[2033]=a[1975],a[2034]=a[1976],a[2035]=a[1977],a[2036]=a[1978],a[2037]=a[1975],a[2038]=a[1976],a[2039]=a[1985],a[2040]=a[1978],a[2041]=a[1975],a[2042]=a[1976],a[2043]=a[1985],a[2044]=a[1978],a[2045]=a[1987],a[2046]=a[1976],a[2047]=a[1989],a[2048]=a[1978],a[2049]=a[1991],a[2050]=a[1992],a[2051]=a[1989],a[2052]=a[1978],a[2053]=a[1991],a[2054]=a[1992],a[2055]=a[1978],a[2056]=a[1998],a[2057]=a[1976],a[2058]=a[2e3],a[2059]=a[1978],a[2060]=a[1975],a[2061]=a[1976],a[2062]=[30,32,31,32,31,31,29,30,29,30,29,31,365],a[2063]=a[1978],a[2064]=a[1975],a[2065]=a[1976],a[2066]=a[1981],a[2067]=a[1978],a[2068]=a[1975],a[2069]=a[1976],a[2070]=a[1985],a[2071]=a[1978],a[2072]=a[1987],a[2073]=a[1976],a[2074]=a[1989],a[2075]=a[1978],a[2076]=a[1991],a[2077]=a[1992],a[2078]=a[1989],a[2079]=a[1978],a[2080]=a[1991],a[2081]=a[1992],a[2082]=a[1978],a[2083]=a[1978],a[2084]=a[1976],a[2085]=a[2e3],a[2086]=a[1978],a[2087]=a[1975],a[2088]=a[1976],a[2089]=a[2e3],a[2090]=a[1978],a[2091]=a[1975],a[2092]=a[1976],a[2093]=a[1981],a[2094]=a[1978],a[2095]=a[1975],a[2096]=a[1976],a[2097]=a[1985],a[2098]=a[1978],a[2099]=a[1975],class{epochStart=new Date(Date.UTC(1918,3,13));epochEnd=new Date(Date.UTC(2043,3,13));errorMsg=`The input date is out of supported range.`;year;month;day;constructor(e){let[t,n,r]=this.parse(e);this.year=t,this.month=n,this.day=r}parse(e){let[t,n,r]=this.toEnglishDigits(e).replace(/[./|,]/g,`-`).trim().split(`-`).map(Number);return[t,n,r]}toEnglishDigits(e){let t=[`०`,`१`,`२`,`३`,`४`,`५`,`६`,`७`,`८`,`९`];return e.replace(/[०१२३४५६७८९]/g,e=>t.indexOf(e).toString())}toDayName(e){return[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`][e]}toAdDate(t,n,r){let i=0;for(let e=1975;e<t;e++)i+=a[e][12];for(let e=0;e<n-1;e++)i+=a[t][e];return i+=r-1,e(this.epochStart,i)}toBsDate(e){let t=e;for(let e in a){if(t>=a[e][12]){t-=a[e][12];continue}for(let n=0;n<12;n++){if(t>=a[e][n]){t-=a[e][n];continue}return{year:Number(e),month:n+1,date:t+1}}}throw Error(this.errorMsg)}toAd(){if(this.year<1975||this.year>2099)throw Error(this.errorMsg);let e=this.toAdDate(this.year,this.month,this.day);return{year:e.getFullYear(),month:e.getMonth()+1,date:e.getDate(),day:this.toDayName(e.getDay())}}toBs(){let e=new Date(Date.UTC(this.year,this.month-1,this.day));if(!i(e,{start:n(this.epochStart),end:r(this.epochEnd)}))throw Error(this.errorMsg);let a=t(e,this.epochStart);return{...this.toBsDate(a),day:this.toDayName(e.getUTCDay())}}}})();