acsi-core 1.2.16 → 1.2.18

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/dist/index.js CHANGED
@@ -3498,25 +3498,43 @@ var CustomSelectOption = function CustomSelectOption(_ref) {
3498
3498
  }, rest));
3499
3499
  };
3500
3500
 
3501
+ var isDateOnlyFormat = function isDateOnlyFormat(fmt) {
3502
+ return !/[Hhms]/.test(fmt);
3503
+ };
3504
+ var parseOffsetToMinutes = function parseOffsetToMinutes(cleanOffset) {
3505
+ if (/^[+-]?\d+$/.test(cleanOffset)) {
3506
+ return parseInt(cleanOffset, 10) * 60;
3507
+ }
3508
+ return moment().utcOffset(cleanOffset).utcOffset();
3509
+ };
3501
3510
  var utcToLocalTime = (function (time, FORMAT) {
3502
3511
  if (time === DATE_MIN_VALUE || time == null) return "";
3503
3512
  var timezone = localStorage.getItem(TIMEZONE_ID) || "";
3513
+ var fmt = FORMAT || "yyyy-MM-DD";
3504
3514
  try {
3505
3515
  if (!timezone) {
3506
- return moment.utc(time).local().format(FORMAT || "yyyy-MM-DD");
3516
+ if (isDateOnlyFormat(fmt)) {
3517
+ var localOffset = moment().utcOffset();
3518
+ if (localOffset <= 0) return moment.utc(time).format(fmt);
3519
+ }
3520
+ return moment.utc(time).local().format(fmt);
3507
3521
  }
3508
3522
  var isOffset = /^(UTC|GMT)?[+-]/.test(timezone);
3509
3523
  if (isOffset) {
3510
3524
  var cleanOffset = timezone.replace(/UTC|GMT/gi, "").trim();
3511
- var offsetMinutes;
3512
- if (/^[+-]?\d+$/.test(cleanOffset)) {
3513
- offsetMinutes = parseInt(cleanOffset, 10) * 60;
3514
- } else {
3515
- offsetMinutes = cleanOffset;
3525
+ var offsetMinutes = parseOffsetToMinutes(cleanOffset);
3526
+ if (isDateOnlyFormat(fmt) && offsetMinutes <= 0) {
3527
+ return moment.utc(time).format(fmt);
3528
+ }
3529
+ return moment.utc(time).utcOffset(offsetMinutes).format(fmt);
3530
+ }
3531
+ if (isDateOnlyFormat(fmt)) {
3532
+ var tzOffset = moment.utc(time).tz(timezone).utcOffset();
3533
+ if (tzOffset <= 0) {
3534
+ return moment.utc(time).format(fmt);
3516
3535
  }
3517
- return moment.utc(time).utcOffset(offsetMinutes).format(FORMAT || "yyyy-MM-DD");
3518
3536
  }
3519
- return moment.utc(time).tz(timezone).format(FORMAT || "yyyy-MM-DD");
3537
+ return moment.utc(time).tz(timezone).format(fmt);
3520
3538
  } catch (_unused) {
3521
3539
  return "";
3522
3540
  }