@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
package/CapCondition/index.js
CHANGED
|
@@ -8313,6 +8313,7 @@ exports.isDayjsObject = isDayjsObject;
|
|
|
8313
8313
|
exports.isMomentObject = isMomentObject;
|
|
8314
8314
|
exports.momentToDayjs = momentToDayjs;
|
|
8315
8315
|
exports.normalizeDateValue = normalizeDateValue;
|
|
8316
|
+
exports.toDayjsInTimezone = toDayjsInTimezone;
|
|
8316
8317
|
var _dayjs = _interopRequireDefault(__webpack_require__(87695));
|
|
8317
8318
|
var _advancedFormat = _interopRequireDefault(__webpack_require__(96833));
|
|
8318
8319
|
var _customParseFormat = _interopRequireDefault(__webpack_require__(2825));
|
|
@@ -8424,7 +8425,23 @@ if (!tzIsCallable) {
|
|
|
8424
8425
|
if (_dayjs.default.isDayjs(date)) {
|
|
8425
8426
|
return date.tz(tzName);
|
|
8426
8427
|
}
|
|
8427
|
-
|
|
8428
|
+
// For strings/Dates: interpret the date/time values as being IN the target timezone
|
|
8429
|
+
// (matching moment.tz(string, tz) semantics). dayjs(date).tz(tz) is wrong because
|
|
8430
|
+
// dayjs(date) anchors to the system local timezone, so .tz() converts FROM local TO tz.
|
|
8431
|
+
// Instead: parse as UTC to get raw date/time values, compute the target timezone's offset,
|
|
8432
|
+
// then adjust the UTC timestamp so .tz() produces the intended local time.
|
|
8433
|
+
try {
|
|
8434
|
+
// Validate timezone is a real IANA timezone before applying the offset correction
|
|
8435
|
+
Intl.DateTimeFormat(undefined, {
|
|
8436
|
+
timeZone: tzName
|
|
8437
|
+
});
|
|
8438
|
+
} catch (_unused) {
|
|
8439
|
+
// Invalid timezone — fall back to local time
|
|
8440
|
+
return (0, _dayjs.default)(date);
|
|
8441
|
+
}
|
|
8442
|
+
const asUtc = _dayjs.default.utc(date);
|
|
8443
|
+
const tzOffset = asUtc.tz(tzName).utcOffset(); // target tz offset in minutes
|
|
8444
|
+
return _dayjs.default.utc(asUtc.valueOf() - tzOffset * 60000).tz(tzName);
|
|
8428
8445
|
} catch (error) {
|
|
8429
8446
|
// If timezone is invalid, log error and fall back to local time
|
|
8430
8447
|
logDevError("dayjs.tz: Invalid timezone \"" + tzName + "\"", error);
|
|
@@ -8650,6 +8667,35 @@ function momentToDayjs(value) {
|
|
|
8650
8667
|
return null;
|
|
8651
8668
|
}
|
|
8652
8669
|
|
|
8670
|
+
/**
|
|
8671
|
+
* Converts any supported date value (Moment, Day.js, string, Date) to a Day.js object
|
|
8672
|
+
* in the specified timezone. This is the recommended single entry point for timezone-safe
|
|
8673
|
+
* date conversion — it handles moment-to-dayjs conversion and timezone application in one step,
|
|
8674
|
+
* avoiding the double-offset bug in dayjs-timezone-iana-plugin.
|
|
8675
|
+
*
|
|
8676
|
+
* @param value - Moment, Day.js, string, Date, or null/undefined
|
|
8677
|
+
* @param timezone - Target IANA timezone (e.g., 'Asia/Kolkata', 'America/New_York')
|
|
8678
|
+
* @returns Day.js object in the target timezone, or null if invalid
|
|
8679
|
+
*
|
|
8680
|
+
* @example
|
|
8681
|
+
* toDayjsInTimezone(moment.tz('2025-04-21 00:00', 'Asia/Kolkata'), 'Asia/Kolkata');
|
|
8682
|
+
* // Returns dayjs representing 2025-04-21 00:00 IST
|
|
8683
|
+
*
|
|
8684
|
+
* @example
|
|
8685
|
+
* toDayjsInTimezone(moment.tz('2025-04-21 00:00', 'UTC'), 'Asia/Kolkata');
|
|
8686
|
+
* // Returns dayjs representing 2025-04-21 05:30 IST
|
|
8687
|
+
*/
|
|
8688
|
+
function toDayjsInTimezone(value, timezone) {
|
|
8689
|
+
const dayjsValue = momentToDayjs(value);
|
|
8690
|
+
if (!dayjsValue) return null;
|
|
8691
|
+
|
|
8692
|
+
// Convert via UTC to avoid the double-offset bug in dayjs-timezone-iana-plugin:
|
|
8693
|
+
// calling .tz() on a dayjs that already has a non-zero utcOffset corrupts the value.
|
|
8694
|
+
// Going through .toDate() → dayjs.utc() gives us a clean UTC-mode dayjs that .tz()
|
|
8695
|
+
// correctly converts to the target timezone.
|
|
8696
|
+
return _dayjs.default.utc(dayjsValue.toDate()).tz(timezone);
|
|
8697
|
+
}
|
|
8698
|
+
|
|
8653
8699
|
/**
|
|
8654
8700
|
* Converts a Day.js object to Moment.js, preserving timezone and locale information.
|
|
8655
8701
|
*
|