bn-calendar 1.2.1 → 1.2.3
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/README.md +8 -8
- package/dist/convert-B3CETM-p.mjs +96 -0
- package/dist/convert-CuE2E2-u.cjs +144 -0
- package/dist/index.cjs +1118 -1
- package/dist/index.d.cts +18 -2
- package/dist/index.d.mts +18 -2
- package/dist/index.mjs +1115 -1
- package/dist/{types-x2X_wAiB.d.cts → types-B8dz3JYA.d.mts} +17 -1
- package/dist/{types-dBV02J9_.d.mts → types-D3WdI9_e.d.cts} +16 -0
- package/dist/{types-CCT6pdoz.d.cts → types-DNIQWvTX.d.mts} +16 -0
- package/dist/{types-DuIqPJJ1.d.mts → types-L7OC1yyG.d.cts} +17 -1
- package/dist/types.cjs +16 -0
- package/dist/types.d.cts +17 -1
- package/dist/types.d.mts +17 -1
- package/dist/types.mjs +17 -1
- package/dist/utils.cjs +21 -1
- package/dist/utils.d.cts +17 -1
- package/dist/utils.d.mts +17 -1
- package/dist/utils.mjs +19 -1
- package/package.json +4 -1
- package/dist/convert-3jw8Rx7e.cjs +0 -1
- package/dist/convert-Byg6yAIU.mjs +0 -1
package/README.md
CHANGED
|
@@ -96,10 +96,10 @@ import { BanglaCalendar } from 'bn-calendar';
|
|
|
96
96
|
- [Quick Examples](#quick-examples)
|
|
97
97
|
- [API Reference](#api-reference)
|
|
98
98
|
- [Constructor](#constructor)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
- [Constructor Signatures](#constructor-signatures)
|
|
100
|
+
- [Parameters](#parameters)
|
|
101
|
+
- [Behavior](#behavior)
|
|
102
|
+
- [Examples](#examples)
|
|
103
103
|
- [Properties](#properties)
|
|
104
104
|
- [variant](#variant)
|
|
105
105
|
- [year](#year)
|
|
@@ -191,7 +191,7 @@ const date5 = new BanglaCalendar('১৪৩০', '১', '১', { variant: 'revis
|
|
|
191
191
|
|
|
192
192
|
Creates a new `BanglaCalendar` instance from various input formats.
|
|
193
193
|
|
|
194
|
-
|
|
194
|
+
#### Constructor Signatures
|
|
195
195
|
|
|
196
196
|
**Signature 1:** From current date with optional configuration
|
|
197
197
|
|
|
@@ -257,7 +257,7 @@ constructor(
|
|
|
257
257
|
)
|
|
258
258
|
```
|
|
259
259
|
|
|
260
|
-
|
|
260
|
+
#### Parameters
|
|
261
261
|
|
|
262
262
|
- `date`: Various date formats including Bangla date strings, Gregorian date strings, Date objects, timestamps, or individual date components
|
|
263
263
|
- `bnYear`: Bengali year in either Bangla (`০-৯৯৯৯`) or Latin (`0-9999`) digits
|
|
@@ -265,7 +265,7 @@ constructor(
|
|
|
265
265
|
- `bnDate`: Bengali day of month (1-31 or `১-৩১`)
|
|
266
266
|
- `config`: Optional configuration object with `variant` property (`'revised-2019'` or `'revised-1966'`)
|
|
267
267
|
|
|
268
|
-
|
|
268
|
+
#### Behavior
|
|
269
269
|
|
|
270
270
|
- Automatically detects input format and parses accordingly
|
|
271
271
|
- Defaults to current date if no valid input is provided
|
|
@@ -273,7 +273,7 @@ constructor(
|
|
|
273
273
|
- Validates all date components
|
|
274
274
|
- Handles leap years according to the selected variant
|
|
275
275
|
|
|
276
|
-
|
|
276
|
+
#### Examples
|
|
277
277
|
|
|
278
278
|
```typescript
|
|
279
279
|
// Current date
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
//#region node_modules/.pnpm/nhb-toolbox@4.30.1/node_modules/nhb-toolbox/dist/esm/guards/primitives.js
|
|
18
|
+
function isNumber(value) {
|
|
19
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
20
|
+
}
|
|
21
|
+
function isString(value) {
|
|
22
|
+
return typeof value === "string";
|
|
23
|
+
}
|
|
24
|
+
function isInteger(value) {
|
|
25
|
+
return isNumber(value) && Number.isInteger(value);
|
|
26
|
+
}
|
|
27
|
+
function isNonEmptyString(value) {
|
|
28
|
+
return isString(value) && value?.length > 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region node_modules/.pnpm/nhb-toolbox@4.30.1/node_modules/nhb-toolbox/dist/esm/guards/non-primitives.js
|
|
33
|
+
function isArray(value) {
|
|
34
|
+
return Array.isArray(value);
|
|
35
|
+
}
|
|
36
|
+
function isObject(value) {
|
|
37
|
+
return value !== null && typeof value === "object" && !isArray(value);
|
|
38
|
+
}
|
|
39
|
+
function isObjectWithKeys(value, keys) {
|
|
40
|
+
return isObject(value) && keys?.every((key) => key in value);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region node_modules/.pnpm/nhb-toolbox@4.30.1/node_modules/nhb-toolbox/dist/esm/guards/specials.js
|
|
45
|
+
function isDateString(value) {
|
|
46
|
+
return isString(value) && !isNaN(Date.parse(value));
|
|
47
|
+
}
|
|
48
|
+
function isNumericString(value) {
|
|
49
|
+
return isString(value) && value?.trim() !== "" && Number.isFinite(Number(value));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region node_modules/.pnpm/nhb-toolbox@4.30.1/node_modules/nhb-toolbox/dist/esm/number/constants.js
|
|
54
|
+
const BN_DIGITS = /* @__PURE__ */ Object.freeze({
|
|
55
|
+
"০": 0,
|
|
56
|
+
"১": 1,
|
|
57
|
+
"২": 2,
|
|
58
|
+
"৩": 3,
|
|
59
|
+
"৪": 4,
|
|
60
|
+
"৫": 5,
|
|
61
|
+
"৬": 6,
|
|
62
|
+
"৭": 7,
|
|
63
|
+
"৮": 8,
|
|
64
|
+
"৯": 9
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region node_modules/.pnpm/nhb-toolbox@4.30.1/node_modules/nhb-toolbox/dist/esm/number/utilities.js
|
|
69
|
+
function normalizeNumber(num) {
|
|
70
|
+
return isNumber(num) ? num : isNumericString(num) ? Number(num) : void 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region node_modules/.pnpm/nhb-toolbox@4.30.1/node_modules/nhb-toolbox/dist/esm/number/convert.js
|
|
75
|
+
function banglaToDigit(bnDigit, forceNumber = true) {
|
|
76
|
+
if (!isNonEmptyString(bnDigit)) return forceNumber ? NaN : "";
|
|
77
|
+
const digitStr = bnDigit.replace(/[০১২৩৪৫৬৭৮৯]/g, (d) => String(BN_DIGITS[d]));
|
|
78
|
+
if (forceNumber) return Number(digitStr.split("").filter((dig) => !isNaN(Number(dig))).join(""));
|
|
79
|
+
return digitStr;
|
|
80
|
+
}
|
|
81
|
+
function digitToBangla(digit, preserveNonDigit = true) {
|
|
82
|
+
const banglaDigits = Object.keys(BN_DIGITS);
|
|
83
|
+
const _matchAndConvert = (value) => {
|
|
84
|
+
return value.replace(/\d/g, (dig) => banglaDigits[Number(dig)]);
|
|
85
|
+
};
|
|
86
|
+
if (isNumber(digit)) return _matchAndConvert(String(digit));
|
|
87
|
+
if (isNonEmptyString(digit)) {
|
|
88
|
+
const bnDigStr = _matchAndConvert(digit);
|
|
89
|
+
if (preserveNonDigit || isNumericString(digit)) return bnDigStr;
|
|
90
|
+
return bnDigStr.split("").filter((dig) => banglaDigits.includes(dig)).join("");
|
|
91
|
+
}
|
|
92
|
+
return "";
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
//#endregion
|
|
96
|
+
export { isObjectWithKeys as a, isNumber as c, isDateString as i, digitToBangla as n, isInteger as o, normalizeNumber as r, isNonEmptyString as s, banglaToDigit as t };
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
//#region node_modules/.pnpm/nhb-toolbox@4.30.1/node_modules/nhb-toolbox/dist/esm/guards/primitives.js
|
|
19
|
+
function isNumber(value) {
|
|
20
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
21
|
+
}
|
|
22
|
+
function isString(value) {
|
|
23
|
+
return typeof value === "string";
|
|
24
|
+
}
|
|
25
|
+
function isInteger(value) {
|
|
26
|
+
return isNumber(value) && Number.isInteger(value);
|
|
27
|
+
}
|
|
28
|
+
function isNonEmptyString(value) {
|
|
29
|
+
return isString(value) && value?.length > 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region node_modules/.pnpm/nhb-toolbox@4.30.1/node_modules/nhb-toolbox/dist/esm/guards/non-primitives.js
|
|
34
|
+
function isArray(value) {
|
|
35
|
+
return Array.isArray(value);
|
|
36
|
+
}
|
|
37
|
+
function isObject(value) {
|
|
38
|
+
return value !== null && typeof value === "object" && !isArray(value);
|
|
39
|
+
}
|
|
40
|
+
function isObjectWithKeys(value, keys) {
|
|
41
|
+
return isObject(value) && keys?.every((key) => key in value);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region node_modules/.pnpm/nhb-toolbox@4.30.1/node_modules/nhb-toolbox/dist/esm/guards/specials.js
|
|
46
|
+
function isDateString(value) {
|
|
47
|
+
return isString(value) && !isNaN(Date.parse(value));
|
|
48
|
+
}
|
|
49
|
+
function isNumericString(value) {
|
|
50
|
+
return isString(value) && value?.trim() !== "" && Number.isFinite(Number(value));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region node_modules/.pnpm/nhb-toolbox@4.30.1/node_modules/nhb-toolbox/dist/esm/number/constants.js
|
|
55
|
+
const BN_DIGITS = /* @__PURE__ */ Object.freeze({
|
|
56
|
+
"০": 0,
|
|
57
|
+
"১": 1,
|
|
58
|
+
"২": 2,
|
|
59
|
+
"৩": 3,
|
|
60
|
+
"৪": 4,
|
|
61
|
+
"৫": 5,
|
|
62
|
+
"৬": 6,
|
|
63
|
+
"৭": 7,
|
|
64
|
+
"৮": 8,
|
|
65
|
+
"৯": 9
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region node_modules/.pnpm/nhb-toolbox@4.30.1/node_modules/nhb-toolbox/dist/esm/number/utilities.js
|
|
70
|
+
function normalizeNumber(num) {
|
|
71
|
+
return isNumber(num) ? num : isNumericString(num) ? Number(num) : void 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region node_modules/.pnpm/nhb-toolbox@4.30.1/node_modules/nhb-toolbox/dist/esm/number/convert.js
|
|
76
|
+
function banglaToDigit(bnDigit, forceNumber = true) {
|
|
77
|
+
if (!isNonEmptyString(bnDigit)) return forceNumber ? NaN : "";
|
|
78
|
+
const digitStr = bnDigit.replace(/[০১২৩৪৫৬৭৮৯]/g, (d) => String(BN_DIGITS[d]));
|
|
79
|
+
if (forceNumber) return Number(digitStr.split("").filter((dig) => !isNaN(Number(dig))).join(""));
|
|
80
|
+
return digitStr;
|
|
81
|
+
}
|
|
82
|
+
function digitToBangla(digit, preserveNonDigit = true) {
|
|
83
|
+
const banglaDigits = Object.keys(BN_DIGITS);
|
|
84
|
+
const _matchAndConvert = (value) => {
|
|
85
|
+
return value.replace(/\d/g, (dig) => banglaDigits[Number(dig)]);
|
|
86
|
+
};
|
|
87
|
+
if (isNumber(digit)) return _matchAndConvert(String(digit));
|
|
88
|
+
if (isNonEmptyString(digit)) {
|
|
89
|
+
const bnDigStr = _matchAndConvert(digit);
|
|
90
|
+
if (preserveNonDigit || isNumericString(digit)) return bnDigStr;
|
|
91
|
+
return bnDigStr.split("").filter((dig) => banglaDigits.includes(dig)).join("");
|
|
92
|
+
}
|
|
93
|
+
return "";
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
//#endregion
|
|
97
|
+
Object.defineProperty(exports, 'banglaToDigit', {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
get: function () {
|
|
100
|
+
return banglaToDigit;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
Object.defineProperty(exports, 'digitToBangla', {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function () {
|
|
106
|
+
return digitToBangla;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
Object.defineProperty(exports, 'isDateString', {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () {
|
|
112
|
+
return isDateString;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
Object.defineProperty(exports, 'isInteger', {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
get: function () {
|
|
118
|
+
return isInteger;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
Object.defineProperty(exports, 'isNonEmptyString', {
|
|
122
|
+
enumerable: true,
|
|
123
|
+
get: function () {
|
|
124
|
+
return isNonEmptyString;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
Object.defineProperty(exports, 'isNumber', {
|
|
128
|
+
enumerable: true,
|
|
129
|
+
get: function () {
|
|
130
|
+
return isNumber;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
Object.defineProperty(exports, 'isObjectWithKeys', {
|
|
134
|
+
enumerable: true,
|
|
135
|
+
get: function () {
|
|
136
|
+
return isObjectWithKeys;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
Object.defineProperty(exports, 'normalizeNumber', {
|
|
140
|
+
enumerable: true,
|
|
141
|
+
get: function () {
|
|
142
|
+
return normalizeNumber;
|
|
143
|
+
}
|
|
144
|
+
});
|