@rabindrapantha/nepali-bs-data 0.0.0-stage → 0.1.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 +21 -0
- package/README.md +144 -2
- package/dist/index.cjs +1295 -0
- package/dist/index.d.cts +36 -0
- package/dist/index.d.mts +36 -0
- package/dist/index.mjs +1283 -0
- package/package.json +64 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 rabindrapantha
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,145 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @rabindrapantha/nepali-bs-data
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@rabindrapantha/nepali-bs-data)
|
|
4
|
+
[](https://www.npmjs.com/package/@rabindrapantha/nepali-bs-data)
|
|
5
|
+
[](https://opensource.org/license/mit)
|
|
6
|
+
[](https://www.typescriptlang.org)
|
|
7
|
+
|
|
8
|
+
Convert AD dates to Bikram Sambat (BS) and look up Nepali calendar data for BS 2000–2083.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- **Zero dependencies:** Lightweight and side-effect free.
|
|
15
|
+
- **TypeScript support:** Includes full type definitions.
|
|
16
|
+
- **Universal compatibility:** ESM and CommonJS, for Node.js 18+ and modern browsers.
|
|
17
|
+
- **English and Nepali:** Month and weekday names in both.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @rabindrapantha/nepali-bs-data
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
yarn add @rabindrapantha/nepali-bs-data
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pnpm add @rabindrapantha/nepali-bs-data
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
import { adToBs, MONTH_NAMES, MONTH_NAMES_NE } from "@rabindrapantha/nepali-bs-data";
|
|
41
|
+
|
|
42
|
+
const bs = adToBs(new Date(2026, 11, 1)); // 1 December 2026
|
|
43
|
+
console.log(bs);
|
|
44
|
+
// Output: { year: 2083, month: 8, day: 15 }
|
|
45
|
+
|
|
46
|
+
console.log(MONTH_NAMES[bs.month - 1], MONTH_NAMES_NE[bs.month - 1]);
|
|
47
|
+
// Output: Mangsir मंसिर
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
CommonJS:
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
const { adToBs } = require("@rabindrapantha/nepali-bs-data");
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## API Reference
|
|
59
|
+
|
|
60
|
+
### `adToBs(date)`
|
|
61
|
+
|
|
62
|
+
Converts an AD date to BS.
|
|
63
|
+
|
|
64
|
+
#### Parameters
|
|
65
|
+
|
|
66
|
+
| Parameter | Type | Default | Description |
|
|
67
|
+
| :--- | :--- | :--- | :--- |
|
|
68
|
+
| `date` | `Date` | **Required** | The day to convert. The local calendar day is used and the time is ignored. |
|
|
69
|
+
|
|
70
|
+
#### Returns
|
|
71
|
+
|
|
72
|
+
- **`BsDate`**: `{ year: number, month: number, day: number }`. `month` is 1–12, where 1 is Baisakh.
|
|
73
|
+
|
|
74
|
+
#### Throws
|
|
75
|
+
|
|
76
|
+
- **`RangeError`**: for an invalid `Date`, or a day outside 14 April 1943 to 13 April 2027.
|
|
77
|
+
|
|
78
|
+
#### Example
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
adToBs(new Date(2025, 3, 14)); // { year: 2082, month: 1, day: 1 }
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
> JavaScript `Date` months start at 0. Use `new Date(2026, 11, 1)` for 1 December. A string such as `new Date("2026-12-01")` means midnight UTC, which is the previous day in time zones behind UTC.
|
|
85
|
+
|
|
86
|
+
### Lookups
|
|
87
|
+
|
|
88
|
+
| Function | Returns | Description |
|
|
89
|
+
| :--- | :--- | :--- |
|
|
90
|
+
| `daysInMonth(year, month)` | `number` | Days in a BS month. Throws `RangeError` for bad input. |
|
|
91
|
+
| `daysInYear(year)` | `number` | Days in a BS year. Throws `RangeError` for an unsupported year. |
|
|
92
|
+
| `isSupportedYear(year)` | `boolean` | `true` for integer years from 2000 to 2083. |
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
daysInMonth(2082, 1); // 31
|
|
96
|
+
daysInYear(2082); // 365
|
|
97
|
+
isSupportedYear(2084); // false
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Constants
|
|
101
|
+
|
|
102
|
+
| Constant | Description |
|
|
103
|
+
| :--- | :--- |
|
|
104
|
+
| `BS_MIN_YEAR`, `BS_MAX_YEAR` | `2000` and `2083`. |
|
|
105
|
+
| `BS_ANCHOR` | Reference day: BS 2000-01-01 is AD 1943-04-14. |
|
|
106
|
+
| `BS_MONTH_DAYS` | 12 month lengths for each BS year, Baisakh first. Do not modify it. |
|
|
107
|
+
| `MONTH_NAMES`, `MONTH_NAMES_NE` | 12 month names, Baisakh first. |
|
|
108
|
+
| `WEEKDAY_NAMES`, `WEEKDAY_NAMES_NE` | 7 weekday names, in `Date.getDay()` order (0 is Sunday). |
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Supported Range
|
|
113
|
+
|
|
114
|
+
Only BS 2000–2083 is supported, so `adToBs` throws for dates from **14 April 2027** onward. BS to AD conversion is not included.
|
|
115
|
+
|
|
116
|
+
The data is provided without any guarantee. Verify dates independently where an exact date matters.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Contributing
|
|
121
|
+
|
|
122
|
+
Contributions, issues, and feature requests are welcome!
|
|
123
|
+
|
|
124
|
+
1. Fork the repository.
|
|
125
|
+
2. Install dependencies with [bun](https://bun.sh) (`bun install`).
|
|
126
|
+
3. Create your feature branch (`git checkout -b feat/amazing-feature`).
|
|
127
|
+
4. Commit your changes using [Conventional Commits](https://www.conventionalcommits.org) (`git commit -m 'feat(nepali-bs-data): add amazing feature'`).
|
|
128
|
+
5. Push to the branch (`git push origin feat/amazing-feature`).
|
|
129
|
+
6. Open a Pull Request.
|
|
130
|
+
|
|
131
|
+
Please ensure all checks pass before submitting a PR:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
bun run test
|
|
135
|
+
bun run typecheck
|
|
136
|
+
bun run build
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Contribute only calendar data that can be released under the MIT License.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
Distributed under the MIT License. See [`LICENSE`](LICENSE) for more information.
|