nhb-toolbox 4.30.10 → 4.30.13
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/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
All notable changes to the package will be documented here.
|
|
6
6
|
|
|
7
|
+
## [4.30.13] - 2026-05-19
|
|
8
|
+
|
|
9
|
+
- **Fixed** *Chronos plugin method* `formatBangla()` to use `variant` from options properly to handle variant dependent calculations.
|
|
10
|
+
|
|
11
|
+
## [4.30.11] - 2026-05-17
|
|
12
|
+
|
|
13
|
+
- **Updated** the *time-zone* abbreviation matching logic of *Chronos plugin method* `getTimeZoneNameShort()` (alias: `getTimeZoneNameAbbr()`) and fixed the caching issue.
|
|
14
|
+
|
|
7
15
|
## [4.30.10] - 2026-05-16
|
|
8
16
|
|
|
9
17
|
- **Added** new *utility types*: `PropertyOptional<T, Keys>` and `PropertyRequired<T, Keys>`.
|
|
@@ -54,14 +54,15 @@ const banglaPlugin = ($Chronos) => {
|
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
56
|
$Chronos.prototype.formatBangla = function (fmt, opts) {
|
|
57
|
+
const { variant } = opts ?? {};
|
|
57
58
|
const { hour, minute, second, millisecond } = this;
|
|
58
59
|
const D_NAME = constants_1.BN_DAYS[this.weekDay];
|
|
59
|
-
const { monthIdx } = $bnDaysMonthIdx($Date(this),
|
|
60
|
+
const { monthIdx } = $bnDaysMonthIdx($Date(this), variant);
|
|
60
61
|
const M_NAME = constants_1.BN_MONTHS[monthIdx];
|
|
61
|
-
const month = this.getBanglaMonth();
|
|
62
|
+
const month = this.getBanglaMonth({ variant });
|
|
62
63
|
const year = (0, helpers_1._padShunno)(this.getBanglaYear(), 4);
|
|
63
|
-
const date = this.getBanglaDay();
|
|
64
|
-
const seasonName = this.getBanglaSeasonName();
|
|
64
|
+
const date = this.getBanglaDay({ variant });
|
|
65
|
+
const seasonName = this.getBanglaSeasonName({ variant });
|
|
65
66
|
const offset = (0, convert_1.digitToBangla)(this.getTimeZoneOffset());
|
|
66
67
|
const dateComponents = {
|
|
67
68
|
YYYY: year,
|
|
@@ -48,10 +48,14 @@ const timeZonePlugin = ($Chronos) => {
|
|
|
48
48
|
}
|
|
49
49
|
return tzIds;
|
|
50
50
|
}, new Map()));
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
const _buildTzNameAbbrMap = () => {
|
|
52
|
+
const result = [];
|
|
53
|
+
for (const [tzAbbr, { offset, tzName }] of Object.entries(timezone_1.TIME_ZONES)) {
|
|
54
|
+
result.unshift([offset, { tzAbbr, tzName }]);
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
};
|
|
58
|
+
const TZ_NAME_ABBR_MAP = new Map(_buildTzNameAbbrMap());
|
|
55
59
|
const _getTimeZoneId = (utc) => {
|
|
56
60
|
const tzIds = TZ_ID_MAP.get(utc);
|
|
57
61
|
if (!tzIds || tzIds?.length === 0)
|
|
@@ -121,12 +125,13 @@ const timeZonePlugin = ($Chronos) => {
|
|
|
121
125
|
if (!utc && tracker && _isValidTzAbbr(tracker))
|
|
122
126
|
return tracker;
|
|
123
127
|
if ((0, guards_1.isValidUTCOffset)(tzMapKey)) {
|
|
124
|
-
if (TZ_ABBR_CACHE.has(tzMapKey))
|
|
128
|
+
if (TZ_ABBR_CACHE.has(tzMapKey)) {
|
|
125
129
|
return TZ_ABBR_CACHE.get(tzMapKey);
|
|
126
|
-
if (TZ_NAME_ABBR_MAP.has(tzMapKey)) {
|
|
127
|
-
return TZ_NAME_ABBR_MAP.get(tzMapKey)?.tzAbbr;
|
|
128
130
|
}
|
|
129
131
|
const tzName = _resolveTzName(tzMapKey);
|
|
132
|
+
if (!tzName && TZ_NAME_ABBR_MAP.has(tzMapKey)) {
|
|
133
|
+
return TZ_NAME_ABBR_MAP.get(tzMapKey)?.tzAbbr;
|
|
134
|
+
}
|
|
130
135
|
if (tzName) {
|
|
131
136
|
const tzAbbr = _abbreviate(tzName);
|
|
132
137
|
TZ_ABBR_CACHE.set(tzMapKey, tzAbbr);
|
|
@@ -134,10 +139,12 @@ const timeZonePlugin = ($Chronos) => {
|
|
|
134
139
|
}
|
|
135
140
|
}
|
|
136
141
|
const zone = _getTimeZoneName(tzMapKey, $Date(this)) ?? UTC;
|
|
137
|
-
|
|
138
|
-
|
|
142
|
+
const fallbackKey = `name-${zone}`;
|
|
143
|
+
if (TZ_ABBR_CACHE.has(fallbackKey)) {
|
|
144
|
+
return TZ_ABBR_CACHE.get(fallbackKey);
|
|
145
|
+
}
|
|
139
146
|
const customAbbr = (0, guards_1.isValidUTCOffset)(zone) ? zone : _abbreviate(zone);
|
|
140
|
-
TZ_ABBR_CACHE.set(
|
|
147
|
+
TZ_ABBR_CACHE.set(fallbackKey, customAbbr);
|
|
141
148
|
return customAbbr;
|
|
142
149
|
};
|
|
143
150
|
$Chronos.prototype.getTimeZoneNameAbbr = function (utc) {
|
|
@@ -51,14 +51,15 @@ export const banglaPlugin = ($Chronos) => {
|
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
53
|
$Chronos.prototype.formatBangla = function (fmt, opts) {
|
|
54
|
+
const { variant } = opts ?? {};
|
|
54
55
|
const { hour, minute, second, millisecond } = this;
|
|
55
56
|
const D_NAME = BN_DAYS[this.weekDay];
|
|
56
|
-
const { monthIdx } = $bnDaysMonthIdx($Date(this),
|
|
57
|
+
const { monthIdx } = $bnDaysMonthIdx($Date(this), variant);
|
|
57
58
|
const M_NAME = BN_MONTHS[monthIdx];
|
|
58
|
-
const month = this.getBanglaMonth();
|
|
59
|
+
const month = this.getBanglaMonth({ variant });
|
|
59
60
|
const year = _padShunno(this.getBanglaYear(), 4);
|
|
60
|
-
const date = this.getBanglaDay();
|
|
61
|
-
const seasonName = this.getBanglaSeasonName();
|
|
61
|
+
const date = this.getBanglaDay({ variant });
|
|
62
|
+
const seasonName = this.getBanglaSeasonName({ variant });
|
|
62
63
|
const offset = digitToBangla(this.getTimeZoneOffset());
|
|
63
64
|
const dateComponents = {
|
|
64
65
|
YYYY: year,
|
|
@@ -45,10 +45,14 @@ export const timeZonePlugin = ($Chronos) => {
|
|
|
45
45
|
}
|
|
46
46
|
return tzIds;
|
|
47
47
|
}, new Map()));
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
const _buildTzNameAbbrMap = () => {
|
|
49
|
+
const result = [];
|
|
50
|
+
for (const [tzAbbr, { offset, tzName }] of Object.entries(TIME_ZONES)) {
|
|
51
|
+
result.unshift([offset, { tzAbbr, tzName }]);
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
const TZ_NAME_ABBR_MAP = new Map(_buildTzNameAbbrMap());
|
|
52
56
|
const _getTimeZoneId = (utc) => {
|
|
53
57
|
const tzIds = TZ_ID_MAP.get(utc);
|
|
54
58
|
if (!tzIds || tzIds?.length === 0)
|
|
@@ -118,12 +122,13 @@ export const timeZonePlugin = ($Chronos) => {
|
|
|
118
122
|
if (!utc && tracker && _isValidTzAbbr(tracker))
|
|
119
123
|
return tracker;
|
|
120
124
|
if (isValidUTCOffset(tzMapKey)) {
|
|
121
|
-
if (TZ_ABBR_CACHE.has(tzMapKey))
|
|
125
|
+
if (TZ_ABBR_CACHE.has(tzMapKey)) {
|
|
122
126
|
return TZ_ABBR_CACHE.get(tzMapKey);
|
|
123
|
-
if (TZ_NAME_ABBR_MAP.has(tzMapKey)) {
|
|
124
|
-
return TZ_NAME_ABBR_MAP.get(tzMapKey)?.tzAbbr;
|
|
125
127
|
}
|
|
126
128
|
const tzName = _resolveTzName(tzMapKey);
|
|
129
|
+
if (!tzName && TZ_NAME_ABBR_MAP.has(tzMapKey)) {
|
|
130
|
+
return TZ_NAME_ABBR_MAP.get(tzMapKey)?.tzAbbr;
|
|
131
|
+
}
|
|
127
132
|
if (tzName) {
|
|
128
133
|
const tzAbbr = _abbreviate(tzName);
|
|
129
134
|
TZ_ABBR_CACHE.set(tzMapKey, tzAbbr);
|
|
@@ -131,10 +136,12 @@ export const timeZonePlugin = ($Chronos) => {
|
|
|
131
136
|
}
|
|
132
137
|
}
|
|
133
138
|
const zone = _getTimeZoneName(tzMapKey, $Date(this)) ?? UTC;
|
|
134
|
-
|
|
135
|
-
|
|
139
|
+
const fallbackKey = `name-${zone}`;
|
|
140
|
+
if (TZ_ABBR_CACHE.has(fallbackKey)) {
|
|
141
|
+
return TZ_ABBR_CACHE.get(fallbackKey);
|
|
142
|
+
}
|
|
136
143
|
const customAbbr = isValidUTCOffset(zone) ? zone : _abbreviate(zone);
|
|
137
|
-
TZ_ABBR_CACHE.set(
|
|
144
|
+
TZ_ABBR_CACHE.set(fallbackKey, customAbbr);
|
|
138
145
|
return customAbbr;
|
|
139
146
|
};
|
|
140
147
|
$Chronos.prototype.getTimeZoneNameAbbr = function (utc) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nhb-toolbox",
|
|
3
|
-
"version": "4.30.
|
|
3
|
+
"version": "4.30.13",
|
|
4
4
|
"description": "A versatile collection of smart, efficient, and reusable utility functions, classes and types for everyday development needs.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@types/node": "^25.8.0",
|
|
50
50
|
"husky": "^9.1.7",
|
|
51
51
|
"jest": "^30.4.2",
|
|
52
|
-
"lint-staged": "^17.0.
|
|
52
|
+
"lint-staged": "^17.0.5",
|
|
53
53
|
"nhb-scripts": "^1.9.2",
|
|
54
54
|
"ts-jest": "^29.4.9",
|
|
55
55
|
"typescript": "^6.0.3"
|