autoql-fe-utils 1.7.18 → 1.7.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.
@@ -18817,18 +18817,47 @@
18817
18817
  var removeSingleQuoteEscape = (input) => {
18818
18818
  return input.substring(1, input.length - 1).replace("''", "'");
18819
18819
  };
18820
+ var getHourRangeFromIsoArray = (isoArray) => {
18821
+ const date0 = isoArray[0];
18822
+ const date1 = isoArray[1];
18823
+ const isoString0 = date0.trim();
18824
+ const isoString1 = date1.trim();
18825
+ const dateDayJS0 = dayjsWithPlugins_default(isoString0).utc();
18826
+ const dateDayJS1 = dayjsWithPlugins_default(isoString1).utc();
18827
+ const diffHours = dateDayJS1.diff(dateDayJS0, "hour", true);
18828
+ if (!date0 || !date1 || !diffHours || isNaN(diffHours)) {
18829
+ return 24;
18830
+ }
18831
+ return diffHours;
18832
+ };
18833
+ var formatISODateWithAutoPrecision = (iso, isoArray) => {
18834
+ if (!iso)
18835
+ return "";
18836
+ const isoString = iso.trim();
18837
+ const dateDayJS = dayjsWithPlugins_default(isoString).utc();
18838
+ const isRange = (isoArray == null ? void 0 : isoArray.length) > 1;
18839
+ const rangeInHours = getHourRangeFromIsoArray(isoArray);
18840
+ if (!isRange || rangeInHours >= 24) {
18841
+ return dateDayJS.format("ll UTC");
18842
+ }
18843
+ if (rangeInHours < 24) {
18844
+ return dateDayJS.format("ll h:mm:ss UTC");
18845
+ }
18846
+ return dateDayJS.format("ll UTC");
18847
+ };
18820
18848
  var formatChunkWithDates = (chunk) => {
18821
18849
  let isDate2 = false;
18822
18850
  let text = chunk.eng;
18823
18851
  let dateArray = [];
18824
18852
  try {
18825
18853
  const textArray = chunk.eng.split(" ");
18854
+ const isoArray = textArray.filter((s) => isISODate(s));
18826
18855
  const textWithDatesArray = textArray.map((str) => {
18827
- const trimmed = str.replace(/\'/g, "");
18828
18856
  if (isISODate(str)) {
18857
+ const trimmed = str.replace(/\'/g, "");
18829
18858
  const dateDayJS = dayjsWithPlugins_default(trimmed).utc();
18830
- const formattedDate = dateDayJS.format("ll");
18831
- if (dateDayJS.isValid()) {
18859
+ const formattedDate = formatISODateWithAutoPrecision(str, isoArray);
18860
+ if (dateDayJS.isValid() && formattedDate) {
18832
18861
  isDate2 = true;
18833
18862
  dateArray.push(dateDayJS);
18834
18863
  return formattedDate;