@capillarytech/blaze-ui 5.1.19 → 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 +47 -1
- package/CapCollapsibleNavbar/index.js.map +1 -1
- package/CapCondition/index.js +47 -1
- package/CapCondition/index.js.map +1 -1
- package/CapDatePicker/index.js +47 -1
- package/CapDatePicker/index.js.map +1 -1
- package/CapDateTimePicker/index.d.ts.map +1 -1
- package/CapDateTimePicker/index.js +56 -9
- package/CapDateTimePicker/index.js.map +1 -1
- package/CapDateTimePicker/types.d.ts +4 -0
- package/CapDateTimePicker/types.d.ts.map +1 -1
- package/CapDateTimeRangePicker/index.js +47 -1
- package/CapDateTimeRangePicker/index.js.map +1 -1
- package/CapEventCalendar/index.js +47 -1
- package/CapEventCalendar/index.js.map +1 -1
- package/CapLanguageProvider/index.js +47 -1
- package/CapLanguageProvider/index.js.map +1 -1
- package/CapNotificationDropdown/index.js +47 -1
- package/CapNotificationDropdown/index.js.map +1 -1
- package/CapTimePicker/index.js +47 -1
- package/CapTimePicker/index.js.map +1 -1
- package/index.js +56 -9
- 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
|
@@ -4234,6 +4234,7 @@ exports.isDayjsObject = isDayjsObject;
|
|
|
4234
4234
|
exports.isMomentObject = isMomentObject;
|
|
4235
4235
|
exports.momentToDayjs = momentToDayjs;
|
|
4236
4236
|
exports.normalizeDateValue = normalizeDateValue;
|
|
4237
|
+
exports.toDayjsInTimezone = toDayjsInTimezone;
|
|
4237
4238
|
var _dayjs = _interopRequireDefault(__webpack_require__(87695));
|
|
4238
4239
|
var _advancedFormat = _interopRequireDefault(__webpack_require__(96833));
|
|
4239
4240
|
var _customParseFormat = _interopRequireDefault(__webpack_require__(2825));
|
|
@@ -4345,7 +4346,23 @@ if (!tzIsCallable) {
|
|
|
4345
4346
|
if (_dayjs.default.isDayjs(date)) {
|
|
4346
4347
|
return date.tz(tzName);
|
|
4347
4348
|
}
|
|
4348
|
-
|
|
4349
|
+
// For strings/Dates: interpret the date/time values as being IN the target timezone
|
|
4350
|
+
// (matching moment.tz(string, tz) semantics). dayjs(date).tz(tz) is wrong because
|
|
4351
|
+
// dayjs(date) anchors to the system local timezone, so .tz() converts FROM local TO tz.
|
|
4352
|
+
// Instead: parse as UTC to get raw date/time values, compute the target timezone's offset,
|
|
4353
|
+
// then adjust the UTC timestamp so .tz() produces the intended local time.
|
|
4354
|
+
try {
|
|
4355
|
+
// Validate timezone is a real IANA timezone before applying the offset correction
|
|
4356
|
+
Intl.DateTimeFormat(undefined, {
|
|
4357
|
+
timeZone: tzName
|
|
4358
|
+
});
|
|
4359
|
+
} catch (_unused) {
|
|
4360
|
+
// Invalid timezone — fall back to local time
|
|
4361
|
+
return (0, _dayjs.default)(date);
|
|
4362
|
+
}
|
|
4363
|
+
const asUtc = _dayjs.default.utc(date);
|
|
4364
|
+
const tzOffset = asUtc.tz(tzName).utcOffset(); // target tz offset in minutes
|
|
4365
|
+
return _dayjs.default.utc(asUtc.valueOf() - tzOffset * 60000).tz(tzName);
|
|
4349
4366
|
} catch (error) {
|
|
4350
4367
|
// If timezone is invalid, log error and fall back to local time
|
|
4351
4368
|
logDevError("dayjs.tz: Invalid timezone \"" + tzName + "\"", error);
|
|
@@ -4571,6 +4588,35 @@ function momentToDayjs(value) {
|
|
|
4571
4588
|
return null;
|
|
4572
4589
|
}
|
|
4573
4590
|
|
|
4591
|
+
/**
|
|
4592
|
+
* Converts any supported date value (Moment, Day.js, string, Date) to a Day.js object
|
|
4593
|
+
* in the specified timezone. This is the recommended single entry point for timezone-safe
|
|
4594
|
+
* date conversion — it handles moment-to-dayjs conversion and timezone application in one step,
|
|
4595
|
+
* avoiding the double-offset bug in dayjs-timezone-iana-plugin.
|
|
4596
|
+
*
|
|
4597
|
+
* @param value - Moment, Day.js, string, Date, or null/undefined
|
|
4598
|
+
* @param timezone - Target IANA timezone (e.g., 'Asia/Kolkata', 'America/New_York')
|
|
4599
|
+
* @returns Day.js object in the target timezone, or null if invalid
|
|
4600
|
+
*
|
|
4601
|
+
* @example
|
|
4602
|
+
* toDayjsInTimezone(moment.tz('2025-04-21 00:00', 'Asia/Kolkata'), 'Asia/Kolkata');
|
|
4603
|
+
* // Returns dayjs representing 2025-04-21 00:00 IST
|
|
4604
|
+
*
|
|
4605
|
+
* @example
|
|
4606
|
+
* toDayjsInTimezone(moment.tz('2025-04-21 00:00', 'UTC'), 'Asia/Kolkata');
|
|
4607
|
+
* // Returns dayjs representing 2025-04-21 05:30 IST
|
|
4608
|
+
*/
|
|
4609
|
+
function toDayjsInTimezone(value, timezone) {
|
|
4610
|
+
const dayjsValue = momentToDayjs(value);
|
|
4611
|
+
if (!dayjsValue) return null;
|
|
4612
|
+
|
|
4613
|
+
// Convert via UTC to avoid the double-offset bug in dayjs-timezone-iana-plugin:
|
|
4614
|
+
// calling .tz() on a dayjs that already has a non-zero utcOffset corrupts the value.
|
|
4615
|
+
// Going through .toDate() → dayjs.utc() gives us a clean UTC-mode dayjs that .tz()
|
|
4616
|
+
// correctly converts to the target timezone.
|
|
4617
|
+
return _dayjs.default.utc(dayjsValue.toDate()).tz(timezone);
|
|
4618
|
+
}
|
|
4619
|
+
|
|
4574
4620
|
/**
|
|
4575
4621
|
* Converts a Day.js object to Moment.js, preserving timezone and locale information.
|
|
4576
4622
|
*
|