@capillarytech/blaze-ui 5.1.18 → 5.1.20
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/CapCollapsibleNavbar/index.js +51 -2
- package/CapCollapsibleNavbar/index.js.map +1 -1
- package/CapCondition/index.js +51 -2
- package/CapCondition/index.js.map +1 -1
- package/CapDatePicker/index.js +51 -2
- package/CapDatePicker/index.js.map +1 -1
- package/CapDateTimePicker/index.d.ts.map +1 -1
- package/CapDateTimePicker/index.js +75 -13
- package/CapDateTimePicker/index.js.map +1 -1
- package/CapDateTimePicker/messages.d.ts +8 -0
- package/CapDateTimePicker/messages.d.ts.map +1 -1
- package/CapDateTimePicker/types.d.ts +4 -0
- package/CapDateTimePicker/types.d.ts.map +1 -1
- package/CapDateTimeRangePicker/index.js +51 -2
- package/CapDateTimeRangePicker/index.js.map +1 -1
- package/CapEventCalendar/index.js +51 -2
- package/CapEventCalendar/index.js.map +1 -1
- package/CapLanguageProvider/index.js +51 -2
- package/CapLanguageProvider/index.js.map +1 -1
- package/CapNotificationDropdown/index.js +51 -2
- package/CapNotificationDropdown/index.js.map +1 -1
- package/CapTimePicker/index.js +51 -2
- package/CapTimePicker/index.js.map +1 -1
- package/index.js +75 -13
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/utils/dayjs.d.ts +19 -0
- package/utils/dayjs.d.ts.map +1 -1
|
@@ -4067,6 +4067,7 @@ exports.isDayjsObject = isDayjsObject;
|
|
|
4067
4067
|
exports.isMomentObject = isMomentObject;
|
|
4068
4068
|
exports.momentToDayjs = momentToDayjs;
|
|
4069
4069
|
exports.normalizeDateValue = normalizeDateValue;
|
|
4070
|
+
exports.toDayjsInTimezone = toDayjsInTimezone;
|
|
4070
4071
|
var _dayjs = _interopRequireDefault(__webpack_require__(87695));
|
|
4071
4072
|
var _advancedFormat = _interopRequireDefault(__webpack_require__(96833));
|
|
4072
4073
|
var _customParseFormat = _interopRequireDefault(__webpack_require__(2825));
|
|
@@ -4178,7 +4179,23 @@ if (!tzIsCallable) {
|
|
|
4178
4179
|
if (_dayjs.default.isDayjs(date)) {
|
|
4179
4180
|
return date.tz(tzName);
|
|
4180
4181
|
}
|
|
4181
|
-
|
|
4182
|
+
// For strings/Dates: interpret the date/time values as being IN the target timezone
|
|
4183
|
+
// (matching moment.tz(string, tz) semantics). dayjs(date).tz(tz) is wrong because
|
|
4184
|
+
// dayjs(date) anchors to the system local timezone, so .tz() converts FROM local TO tz.
|
|
4185
|
+
// Instead: parse as UTC to get raw date/time values, compute the target timezone's offset,
|
|
4186
|
+
// then adjust the UTC timestamp so .tz() produces the intended local time.
|
|
4187
|
+
try {
|
|
4188
|
+
// Validate timezone is a real IANA timezone before applying the offset correction
|
|
4189
|
+
Intl.DateTimeFormat(undefined, {
|
|
4190
|
+
timeZone: tzName
|
|
4191
|
+
});
|
|
4192
|
+
} catch (_unused) {
|
|
4193
|
+
// Invalid timezone — fall back to local time
|
|
4194
|
+
return (0, _dayjs.default)(date);
|
|
4195
|
+
}
|
|
4196
|
+
const asUtc = _dayjs.default.utc(date);
|
|
4197
|
+
const tzOffset = asUtc.tz(tzName).utcOffset(); // target tz offset in minutes
|
|
4198
|
+
return _dayjs.default.utc(asUtc.valueOf() - tzOffset * 60000).tz(tzName);
|
|
4182
4199
|
} catch (error) {
|
|
4183
4200
|
// If timezone is invalid, log error and fall back to local time
|
|
4184
4201
|
logDevError("dayjs.tz: Invalid timezone \"" + tzName + "\"", error);
|
|
@@ -4348,7 +4365,10 @@ function momentToDayjs(value) {
|
|
|
4348
4365
|
const tz = value.tz();
|
|
4349
4366
|
if (tz) {
|
|
4350
4367
|
// Has a named timezone - preserve it
|
|
4351
|
-
|
|
4368
|
+
// dayjs.utc(date) is required here: dayjs(date) anchors to the system local timezone,
|
|
4369
|
+
// causing .tz() to only re-label without converting hours. dayjs.utc(date) creates a
|
|
4370
|
+
// UTC-mode dayjs, which .tz() correctly converts to the target timezone for display.
|
|
4371
|
+
dayjsObj = _dayjs.default.utc(date).tz(tz);
|
|
4352
4372
|
|
|
4353
4373
|
// WORKAROUND: dayjs-timezone-iana-plugin doesn't persist timezone name in standard way
|
|
4354
4374
|
// Store it manually in $x for round-trip conversion fidelity
|
|
@@ -4401,6 +4421,35 @@ function momentToDayjs(value) {
|
|
|
4401
4421
|
return null;
|
|
4402
4422
|
}
|
|
4403
4423
|
|
|
4424
|
+
/**
|
|
4425
|
+
* Converts any supported date value (Moment, Day.js, string, Date) to a Day.js object
|
|
4426
|
+
* in the specified timezone. This is the recommended single entry point for timezone-safe
|
|
4427
|
+
* date conversion — it handles moment-to-dayjs conversion and timezone application in one step,
|
|
4428
|
+
* avoiding the double-offset bug in dayjs-timezone-iana-plugin.
|
|
4429
|
+
*
|
|
4430
|
+
* @param value - Moment, Day.js, string, Date, or null/undefined
|
|
4431
|
+
* @param timezone - Target IANA timezone (e.g., 'Asia/Kolkata', 'America/New_York')
|
|
4432
|
+
* @returns Day.js object in the target timezone, or null if invalid
|
|
4433
|
+
*
|
|
4434
|
+
* @example
|
|
4435
|
+
* toDayjsInTimezone(moment.tz('2025-04-21 00:00', 'Asia/Kolkata'), 'Asia/Kolkata');
|
|
4436
|
+
* // Returns dayjs representing 2025-04-21 00:00 IST
|
|
4437
|
+
*
|
|
4438
|
+
* @example
|
|
4439
|
+
* toDayjsInTimezone(moment.tz('2025-04-21 00:00', 'UTC'), 'Asia/Kolkata');
|
|
4440
|
+
* // Returns dayjs representing 2025-04-21 05:30 IST
|
|
4441
|
+
*/
|
|
4442
|
+
function toDayjsInTimezone(value, timezone) {
|
|
4443
|
+
const dayjsValue = momentToDayjs(value);
|
|
4444
|
+
if (!dayjsValue) return null;
|
|
4445
|
+
|
|
4446
|
+
// Convert via UTC to avoid the double-offset bug in dayjs-timezone-iana-plugin:
|
|
4447
|
+
// calling .tz() on a dayjs that already has a non-zero utcOffset corrupts the value.
|
|
4448
|
+
// Going through .toDate() → dayjs.utc() gives us a clean UTC-mode dayjs that .tz()
|
|
4449
|
+
// correctly converts to the target timezone.
|
|
4450
|
+
return _dayjs.default.utc(dayjsValue.toDate()).tz(timezone);
|
|
4451
|
+
}
|
|
4452
|
+
|
|
4404
4453
|
/**
|
|
4405
4454
|
* Converts a Day.js object to Moment.js, preserving timezone and locale information.
|
|
4406
4455
|
*
|