tsgrid-ui 2.4.0 → 2.5.0
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/CHANGELOG.md +50 -0
- package/dist/tsgrid-ui.css +2 -2
- package/dist/tsgrid-ui.d.ts +15 -0
- package/dist/tsgrid-ui.es6.js +337 -311
- package/dist/tsgrid-ui.es6.js.map +1 -1
- package/dist/tsgrid-ui.es6.min.js +35 -35
- package/dist/tsgrid-ui.js +338 -312
- package/dist/tsgrid-ui.min.css +2 -2
- package/dist/tsgrid-ui.min.js +36 -36
- package/package.json +1 -1
package/dist/tsgrid-ui.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* tsgrid-ui 1.0.x (nightly) (5/13/2026,
|
|
1
|
+
/* tsgrid-ui 1.0.x (nightly) (5/13/2026, 9:14:17 PM) (c) 2014 vitmalina@gmail.com, (c) 2026 DaverSoGT — MIT */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -2694,6 +2694,335 @@ function bindEvents(selector, subject) {
|
|
|
2694
2694
|
});
|
|
2695
2695
|
}
|
|
2696
2696
|
|
|
2697
|
+
// src/tsutils-datetime.ts
|
|
2698
|
+
function _isDate(val, format, retDate, settings) {
|
|
2699
|
+
if (!val) return false;
|
|
2700
|
+
let dt = "Invalid Date";
|
|
2701
|
+
let month, day, year;
|
|
2702
|
+
if (format == null) format = settings.dateFormat;
|
|
2703
|
+
if (val instanceof Date) {
|
|
2704
|
+
year = val.getFullYear();
|
|
2705
|
+
month = val.getMonth() + 1;
|
|
2706
|
+
day = val.getDate();
|
|
2707
|
+
} else if (typeof val === "number" || typeof val === "string" && parseInt(val) == val && parseInt(val) > 0) {
|
|
2708
|
+
const d = new Date(parseInt(String(val)));
|
|
2709
|
+
year = d.getFullYear();
|
|
2710
|
+
month = d.getMonth() + 1;
|
|
2711
|
+
day = d.getDate();
|
|
2712
|
+
} else {
|
|
2713
|
+
let strVal = String(val);
|
|
2714
|
+
if (new RegExp("mon", "ig").test(format)) {
|
|
2715
|
+
format = format.replace(/month/ig, "m").replace(/mon/ig, "m").replace(/dd/ig, "d").replace(/[, ]/ig, "/").replace(/\/\//g, "/").toLowerCase();
|
|
2716
|
+
strVal = strVal.replace(/[, ]/ig, "/").replace(/\/\//g, "/").toLowerCase();
|
|
2717
|
+
for (let m = 0, len = settings.fullmonths.length; m < len; m++) {
|
|
2718
|
+
const t = settings.fullmonths[m] ?? "";
|
|
2719
|
+
strVal = strVal.replace(new RegExp(t, "ig"), String(m + 1)).replace(new RegExp(t.substr(0, 3), "ig"), String(m + 1));
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
const tmp = strVal.replace(/-/g, "/").replace(/\./g, "/").toLowerCase().split("/");
|
|
2723
|
+
const tmp2 = format.replace(/-/g, "/").replace(/\./g, "/").toLowerCase();
|
|
2724
|
+
if (tmp2 === "mm/dd/yyyy") {
|
|
2725
|
+
month = tmp[0];
|
|
2726
|
+
day = tmp[1];
|
|
2727
|
+
year = tmp[2];
|
|
2728
|
+
}
|
|
2729
|
+
if (tmp2 === "m/d/yyyy") {
|
|
2730
|
+
month = tmp[0];
|
|
2731
|
+
day = tmp[1];
|
|
2732
|
+
year = tmp[2];
|
|
2733
|
+
}
|
|
2734
|
+
if (tmp2 === "dd/mm/yyyy") {
|
|
2735
|
+
month = tmp[1];
|
|
2736
|
+
day = tmp[0];
|
|
2737
|
+
year = tmp[2];
|
|
2738
|
+
}
|
|
2739
|
+
if (tmp2 === "d/m/yyyy") {
|
|
2740
|
+
month = tmp[1];
|
|
2741
|
+
day = tmp[0];
|
|
2742
|
+
year = tmp[2];
|
|
2743
|
+
}
|
|
2744
|
+
if (tmp2 === "yyyy/dd/mm") {
|
|
2745
|
+
month = tmp[2];
|
|
2746
|
+
day = tmp[1];
|
|
2747
|
+
year = tmp[0];
|
|
2748
|
+
}
|
|
2749
|
+
if (tmp2 === "yyyy/d/m") {
|
|
2750
|
+
month = tmp[2];
|
|
2751
|
+
day = tmp[1];
|
|
2752
|
+
year = tmp[0];
|
|
2753
|
+
}
|
|
2754
|
+
if (tmp2 === "yyyy/mm/dd") {
|
|
2755
|
+
month = tmp[1];
|
|
2756
|
+
day = tmp[2];
|
|
2757
|
+
year = tmp[0];
|
|
2758
|
+
}
|
|
2759
|
+
if (tmp2 === "yyyy/m/d") {
|
|
2760
|
+
month = tmp[1];
|
|
2761
|
+
day = tmp[2];
|
|
2762
|
+
year = tmp[0];
|
|
2763
|
+
}
|
|
2764
|
+
if (tmp2 === "mm/dd/yy") {
|
|
2765
|
+
month = tmp[0];
|
|
2766
|
+
day = tmp[1];
|
|
2767
|
+
year = tmp[2];
|
|
2768
|
+
}
|
|
2769
|
+
if (tmp2 === "m/d/yy") {
|
|
2770
|
+
month = tmp[0];
|
|
2771
|
+
day = tmp[1];
|
|
2772
|
+
year = parseInt(tmp[2] ?? "0") + 1900;
|
|
2773
|
+
}
|
|
2774
|
+
if (tmp2 === "dd/mm/yy") {
|
|
2775
|
+
month = tmp[1];
|
|
2776
|
+
day = tmp[0];
|
|
2777
|
+
year = parseInt(tmp[2] ?? "0") + 1900;
|
|
2778
|
+
}
|
|
2779
|
+
if (tmp2 === "d/m/yy") {
|
|
2780
|
+
month = tmp[1];
|
|
2781
|
+
day = tmp[0];
|
|
2782
|
+
year = parseInt(tmp[2] ?? "0") + 1900;
|
|
2783
|
+
}
|
|
2784
|
+
if (tmp2 === "yy/dd/mm") {
|
|
2785
|
+
month = tmp[2];
|
|
2786
|
+
day = tmp[1];
|
|
2787
|
+
year = parseInt(tmp[0] ?? "0") + 1900;
|
|
2788
|
+
}
|
|
2789
|
+
if (tmp2 === "yy/d/m") {
|
|
2790
|
+
month = tmp[2];
|
|
2791
|
+
day = tmp[1];
|
|
2792
|
+
year = parseInt(tmp[0] ?? "0") + 1900;
|
|
2793
|
+
}
|
|
2794
|
+
if (tmp2 === "yy/mm/dd") {
|
|
2795
|
+
month = tmp[1];
|
|
2796
|
+
day = tmp[2];
|
|
2797
|
+
year = parseInt(tmp[0] ?? "0") + 1900;
|
|
2798
|
+
}
|
|
2799
|
+
if (tmp2 === "yy/m/d") {
|
|
2800
|
+
month = tmp[1];
|
|
2801
|
+
day = tmp[2];
|
|
2802
|
+
year = parseInt(tmp[0] ?? "0") + 1900;
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
if (!isInt(year)) return false;
|
|
2806
|
+
if (!isInt(month)) return false;
|
|
2807
|
+
if (!isInt(day)) return false;
|
|
2808
|
+
const numYear = +(year ?? 0);
|
|
2809
|
+
const numMonth = +(month ?? 0);
|
|
2810
|
+
const numDay = +(day ?? 0);
|
|
2811
|
+
dt = new Date(numYear, numMonth - 1, numDay);
|
|
2812
|
+
dt.setFullYear(numYear);
|
|
2813
|
+
if (numMonth == null) return false;
|
|
2814
|
+
if (String(dt) === "Invalid Date") return false;
|
|
2815
|
+
if (dt.getMonth() + 1 !== numMonth || dt.getDate() !== numDay || dt.getFullYear() !== numYear) return false;
|
|
2816
|
+
if (retDate === true) return dt;
|
|
2817
|
+
else return true;
|
|
2818
|
+
}
|
|
2819
|
+
function _isTime(val, retTime) {
|
|
2820
|
+
if (val == null) return false;
|
|
2821
|
+
let max;
|
|
2822
|
+
let strVal = String(val).toUpperCase();
|
|
2823
|
+
const am = strVal.indexOf("AM") >= 0;
|
|
2824
|
+
const pm = strVal.indexOf("PM") >= 0;
|
|
2825
|
+
const ampm = pm || am;
|
|
2826
|
+
if (ampm) max = 12;
|
|
2827
|
+
else max = 24;
|
|
2828
|
+
strVal = strVal.replace("AM", "").replace("PM", "").trim();
|
|
2829
|
+
const tmp = strVal.split(":");
|
|
2830
|
+
const tmp0 = tmp[0] ?? "", tmp1 = tmp[1] ?? "", tmp2 = tmp[2] ?? "";
|
|
2831
|
+
let h = parseInt(tmp0 || "0");
|
|
2832
|
+
const m = parseInt(tmp1 || "0"), s = parseInt(tmp2 || "0");
|
|
2833
|
+
if ((!ampm || tmp.length !== 1) && tmp.length !== 2 && tmp.length !== 3) {
|
|
2834
|
+
return false;
|
|
2835
|
+
}
|
|
2836
|
+
if (tmp0 === "" || h < 0 || h > max || !isInt(tmp0) || tmp0.length > 2) {
|
|
2837
|
+
return false;
|
|
2838
|
+
}
|
|
2839
|
+
if (tmp.length > 1 && (tmp1 === "" || m < 0 || m > 59 || !isInt(tmp1) || tmp1.length !== 2)) {
|
|
2840
|
+
return false;
|
|
2841
|
+
}
|
|
2842
|
+
if (tmp.length > 2 && (tmp2 === "" || s < 0 || s > 59 || !isInt(tmp2) || tmp2.length !== 2)) {
|
|
2843
|
+
return false;
|
|
2844
|
+
}
|
|
2845
|
+
if (!ampm && max === h && (m !== 0 || s !== 0)) {
|
|
2846
|
+
return false;
|
|
2847
|
+
}
|
|
2848
|
+
if (ampm && tmp.length === 1 && h === 0) {
|
|
2849
|
+
return false;
|
|
2850
|
+
}
|
|
2851
|
+
if (retTime === true) {
|
|
2852
|
+
if (pm && h !== 12) h += 12;
|
|
2853
|
+
if (am && h === 12) h += 12;
|
|
2854
|
+
return {
|
|
2855
|
+
hours: h,
|
|
2856
|
+
minutes: m,
|
|
2857
|
+
seconds: s
|
|
2858
|
+
};
|
|
2859
|
+
}
|
|
2860
|
+
return true;
|
|
2861
|
+
}
|
|
2862
|
+
function _isDateTime(val, format, retDate, settings) {
|
|
2863
|
+
if (val instanceof Date) {
|
|
2864
|
+
if (retDate !== true) return true;
|
|
2865
|
+
return val;
|
|
2866
|
+
}
|
|
2867
|
+
const intVal = parseInt(String(val));
|
|
2868
|
+
if (intVal === val) {
|
|
2869
|
+
if (intVal < 0) return false;
|
|
2870
|
+
else if (retDate !== true) return true;
|
|
2871
|
+
else return new Date(intVal);
|
|
2872
|
+
}
|
|
2873
|
+
const strVal = String(val);
|
|
2874
|
+
const tmp = strVal.indexOf(" ");
|
|
2875
|
+
if (tmp < 0) {
|
|
2876
|
+
if (strVal.indexOf("T") < 0 || String(new Date(strVal)) == "Invalid Date") return false;
|
|
2877
|
+
else if (retDate !== true) return true;
|
|
2878
|
+
else return new Date(strVal);
|
|
2879
|
+
} else {
|
|
2880
|
+
if (format == null) format = settings.datetimeFormat;
|
|
2881
|
+
const formats = format.split("|");
|
|
2882
|
+
const values = [strVal.substr(0, tmp), strVal.substr(tmp).trim()];
|
|
2883
|
+
if (formats[0] != null) formats[0] = formats[0].trim();
|
|
2884
|
+
if (formats[1]) formats[1] = formats[1].trim();
|
|
2885
|
+
const tmp1 = _isDate(values[0], formats[0], true, settings);
|
|
2886
|
+
const tmp2 = _isTime(values[1], true);
|
|
2887
|
+
if (tmp1 !== false && tmp2 !== false) {
|
|
2888
|
+
if (retDate !== true) return true;
|
|
2889
|
+
const dt1 = tmp1;
|
|
2890
|
+
const t2 = tmp2;
|
|
2891
|
+
dt1.setHours(t2.hours);
|
|
2892
|
+
dt1.setMinutes(t2.minutes);
|
|
2893
|
+
dt1.setSeconds(t2.seconds);
|
|
2894
|
+
return dt1;
|
|
2895
|
+
} else {
|
|
2896
|
+
return false;
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2900
|
+
function _age(dateStr) {
|
|
2901
|
+
let d1;
|
|
2902
|
+
if (dateStr === "" || dateStr == null) return "";
|
|
2903
|
+
if (dateStr instanceof Date) {
|
|
2904
|
+
d1 = dateStr;
|
|
2905
|
+
} else if (typeof dateStr === "number" || typeof dateStr === "string" && parseInt(dateStr) == dateStr && parseInt(dateStr) > 0) {
|
|
2906
|
+
d1 = new Date(parseInt(String(dateStr)));
|
|
2907
|
+
} else {
|
|
2908
|
+
d1 = new Date(String(dateStr));
|
|
2909
|
+
}
|
|
2910
|
+
if (String(d1) === "Invalid Date") return "";
|
|
2911
|
+
const d2 = /* @__PURE__ */ new Date();
|
|
2912
|
+
const sec = (d2.getTime() - d1.getTime()) / 1e3;
|
|
2913
|
+
let amount = 0;
|
|
2914
|
+
let type = "";
|
|
2915
|
+
if (sec < 0) {
|
|
2916
|
+
amount = 0;
|
|
2917
|
+
type = "sec";
|
|
2918
|
+
} else if (sec < 60) {
|
|
2919
|
+
amount = Math.floor(sec);
|
|
2920
|
+
type = "sec";
|
|
2921
|
+
if (sec < 0) {
|
|
2922
|
+
amount = 0;
|
|
2923
|
+
type = "sec";
|
|
2924
|
+
}
|
|
2925
|
+
} else if (sec < 60 * 60) {
|
|
2926
|
+
amount = Math.floor(sec / 60);
|
|
2927
|
+
type = "min";
|
|
2928
|
+
} else if (sec < 24 * 60 * 60) {
|
|
2929
|
+
amount = Math.floor(sec / 60 / 60);
|
|
2930
|
+
type = "hour";
|
|
2931
|
+
} else if (sec < 30 * 24 * 60 * 60) {
|
|
2932
|
+
amount = Math.floor(sec / 24 / 60 / 60);
|
|
2933
|
+
type = "day";
|
|
2934
|
+
} else if (sec < 365 * 24 * 60 * 60) {
|
|
2935
|
+
amount = Math.floor(sec / 30 / 24 / 60 / 60 * 10) / 10;
|
|
2936
|
+
type = "month";
|
|
2937
|
+
} else if (sec < 365 * 4 * 24 * 60 * 60) {
|
|
2938
|
+
amount = Math.floor(sec / 365 / 24 / 60 / 60 * 10) / 10;
|
|
2939
|
+
type = "year";
|
|
2940
|
+
} else if (sec >= 365 * 4 * 24 * 60 * 60) {
|
|
2941
|
+
amount = Math.floor(sec / 365.25 / 24 / 60 / 60 * 10) / 10;
|
|
2942
|
+
type = "year";
|
|
2943
|
+
}
|
|
2944
|
+
return amount + " " + type + (amount > 1 ? "s" : "");
|
|
2945
|
+
}
|
|
2946
|
+
function _interval(value) {
|
|
2947
|
+
let ret = "";
|
|
2948
|
+
if (value < 100) {
|
|
2949
|
+
ret = "< 0.01 sec";
|
|
2950
|
+
} else if (value < 1e3) {
|
|
2951
|
+
ret = Math.floor(value / 10) / 100 + " sec";
|
|
2952
|
+
} else if (value < 1e4) {
|
|
2953
|
+
ret = Math.floor(value / 100) / 10 + " sec";
|
|
2954
|
+
} else if (value < 6e4) {
|
|
2955
|
+
ret = Math.floor(value / 1e3) + " secs";
|
|
2956
|
+
} else if (value < 36e5) {
|
|
2957
|
+
ret = Math.floor(value / 6e4) + " mins";
|
|
2958
|
+
} else if (value < 864e5) {
|
|
2959
|
+
ret = Math.floor(value / 36e5 * 10) / 10 + " hours";
|
|
2960
|
+
} else if (value < 2628e6) {
|
|
2961
|
+
ret = Math.floor(value / 864e5 * 10) / 10 + " days";
|
|
2962
|
+
} else if (value < 31536e6) {
|
|
2963
|
+
ret = Math.floor(value / 2628e6 * 10) / 10 + " months";
|
|
2964
|
+
} else {
|
|
2965
|
+
ret = Math.floor(value / 31536e5) / 10 + " years";
|
|
2966
|
+
}
|
|
2967
|
+
return ret;
|
|
2968
|
+
}
|
|
2969
|
+
function _formatDate(dateStr, format, settings) {
|
|
2970
|
+
if (!format) format = settings.dateFormat;
|
|
2971
|
+
if (dateStr === "" || dateStr == null || typeof dateStr === "object" && !dateStr.getMonth) return "";
|
|
2972
|
+
let dt = new Date(dateStr);
|
|
2973
|
+
if (isInt(dateStr)) dt = new Date(Number(dateStr));
|
|
2974
|
+
if (String(dt) === "Invalid Date") return "";
|
|
2975
|
+
const year = dt.getFullYear();
|
|
2976
|
+
const month = dt.getMonth();
|
|
2977
|
+
const date = dt.getDate();
|
|
2978
|
+
return format.toLowerCase().replace("month", settings.fullmonths[month] ?? "").replace("mon", settings.shortmonths[month] ?? "").replace(/yyyy/g, ("000" + year).slice(-4)).replace(/yyy/g, ("000" + year).slice(-4)).replace(/yy/g, ("0" + year).slice(-2)).replace(/(^|[^a-z$])y/g, "$1" + year).replace(/mm/g, ("0" + (month + 1)).slice(-2)).replace(/dd/g, ("0" + date).slice(-2)).replace(/th/g, date == 1 ? "st" : "th").replace(/th/g, date == 2 ? "nd" : "th").replace(/th/g, date == 3 ? "rd" : "th").replace(/(^|[^a-z$])m/g, "$1" + (month + 1)).replace(/(^|[^a-z$])d/g, "$1" + date);
|
|
2979
|
+
}
|
|
2980
|
+
function _formatTime(dateStr, format, settings) {
|
|
2981
|
+
if (!format) format = settings.timeFormat;
|
|
2982
|
+
if (dateStr === "" || dateStr == null || typeof dateStr === "object" && !dateStr.getMonth) return "";
|
|
2983
|
+
let dt = new Date(dateStr);
|
|
2984
|
+
if (isInt(dateStr)) dt = new Date(Number(dateStr));
|
|
2985
|
+
if (_isTime(dateStr)) {
|
|
2986
|
+
const tmp = _isTime(dateStr, true);
|
|
2987
|
+
dt = /* @__PURE__ */ new Date();
|
|
2988
|
+
dt.setHours(tmp.hours);
|
|
2989
|
+
dt.setMinutes(tmp.minutes);
|
|
2990
|
+
}
|
|
2991
|
+
if (String(dt) === "Invalid Date") return "";
|
|
2992
|
+
if (format == "h12") format = "hh:mi pm";
|
|
2993
|
+
let type = "am";
|
|
2994
|
+
let hour = dt.getHours();
|
|
2995
|
+
const h24 = dt.getHours();
|
|
2996
|
+
let min = dt.getMinutes();
|
|
2997
|
+
let sec = dt.getSeconds();
|
|
2998
|
+
if (min < 10) min = "0" + min;
|
|
2999
|
+
if (sec < 10) sec = "0" + sec;
|
|
3000
|
+
if (format.indexOf("am") !== -1 || format.indexOf("pm") !== -1) {
|
|
3001
|
+
if (hour >= 12) type = "pm";
|
|
3002
|
+
if (hour > 12) hour = hour - 12;
|
|
3003
|
+
if (hour === 0) hour = 12;
|
|
3004
|
+
}
|
|
3005
|
+
const hourStr = String(hour);
|
|
3006
|
+
const minStr = String(min);
|
|
3007
|
+
const secStr = String(sec);
|
|
3008
|
+
const h24Str = String(h24);
|
|
3009
|
+
return format.toLowerCase().replace("am", type).replace("pm", type).replace("hhh", Number(hour) < 10 ? "0" + hourStr : hourStr).replace("hh24", h24 < 10 ? "0" + h24Str : h24Str).replace("h24", h24Str).replace("hh", hourStr).replace("mm", minStr).replace("mi", minStr).replace("ss", secStr).replace(/(^|[^a-z$])h/g, "$1" + hourStr).replace(/(^|[^a-z$])m/g, "$1" + minStr).replace(/(^|[^a-z$])s/g, "$1" + secStr);
|
|
3010
|
+
}
|
|
3011
|
+
function _formatDateTime(dateStr, format, settings) {
|
|
3012
|
+
let fmt;
|
|
3013
|
+
if (dateStr === "" || dateStr == null || typeof dateStr === "object" && !dateStr.getMonth) return "";
|
|
3014
|
+
if (typeof format !== "string") {
|
|
3015
|
+
fmt = [settings.dateFormat, settings.timeFormat];
|
|
3016
|
+
} else {
|
|
3017
|
+
fmt = format.split("|");
|
|
3018
|
+
if (fmt[0] != null) fmt[0] = fmt[0].trim();
|
|
3019
|
+
fmt[1] = fmt.length > 1 ? (fmt[1] ?? "").trim() : settings.timeFormat;
|
|
3020
|
+
}
|
|
3021
|
+
if (fmt[1] === "h12") fmt[1] = "h:m pm";
|
|
3022
|
+
if (fmt[1] === "h24") fmt[1] = "h24:m";
|
|
3023
|
+
return _formatDate(dateStr, fmt[0], settings) + " " + _formatTime(dateStr, fmt[1], settings);
|
|
3024
|
+
}
|
|
3025
|
+
|
|
2697
3026
|
// src/tsutils.ts
|
|
2698
3027
|
var query7 = query;
|
|
2699
3028
|
var Utils = class {
|
|
@@ -2894,275 +3223,19 @@ var Utils = class {
|
|
|
2894
3223
|
return isIpAddress(val);
|
|
2895
3224
|
}
|
|
2896
3225
|
isDate(val, format, retDate) {
|
|
2897
|
-
|
|
2898
|
-
let dt = "Invalid Date";
|
|
2899
|
-
let month, day, year;
|
|
2900
|
-
if (format == null) format = this.settings.dateFormat;
|
|
2901
|
-
if (val instanceof Date) {
|
|
2902
|
-
year = val.getFullYear();
|
|
2903
|
-
month = val.getMonth() + 1;
|
|
2904
|
-
day = val.getDate();
|
|
2905
|
-
} else if (typeof val === "number" || typeof val === "string" && parseInt(val) == val && parseInt(val) > 0) {
|
|
2906
|
-
const d = new Date(parseInt(String(val)));
|
|
2907
|
-
year = d.getFullYear();
|
|
2908
|
-
month = d.getMonth() + 1;
|
|
2909
|
-
day = d.getDate();
|
|
2910
|
-
} else {
|
|
2911
|
-
let strVal = String(val);
|
|
2912
|
-
if (new RegExp("mon", "ig").test(format)) {
|
|
2913
|
-
format = format.replace(/month/ig, "m").replace(/mon/ig, "m").replace(/dd/ig, "d").replace(/[, ]/ig, "/").replace(/\/\//g, "/").toLowerCase();
|
|
2914
|
-
strVal = strVal.replace(/[, ]/ig, "/").replace(/\/\//g, "/").toLowerCase();
|
|
2915
|
-
for (let m = 0, len = this.settings.fullmonths.length; m < len; m++) {
|
|
2916
|
-
const t = this.settings.fullmonths[m] ?? "";
|
|
2917
|
-
strVal = strVal.replace(new RegExp(t, "ig"), String(m + 1)).replace(new RegExp(t.substr(0, 3), "ig"), String(m + 1));
|
|
2918
|
-
}
|
|
2919
|
-
}
|
|
2920
|
-
const tmp = strVal.replace(/-/g, "/").replace(/\./g, "/").toLowerCase().split("/");
|
|
2921
|
-
const tmp2 = format.replace(/-/g, "/").replace(/\./g, "/").toLowerCase();
|
|
2922
|
-
if (tmp2 === "mm/dd/yyyy") {
|
|
2923
|
-
month = tmp[0];
|
|
2924
|
-
day = tmp[1];
|
|
2925
|
-
year = tmp[2];
|
|
2926
|
-
}
|
|
2927
|
-
if (tmp2 === "m/d/yyyy") {
|
|
2928
|
-
month = tmp[0];
|
|
2929
|
-
day = tmp[1];
|
|
2930
|
-
year = tmp[2];
|
|
2931
|
-
}
|
|
2932
|
-
if (tmp2 === "dd/mm/yyyy") {
|
|
2933
|
-
month = tmp[1];
|
|
2934
|
-
day = tmp[0];
|
|
2935
|
-
year = tmp[2];
|
|
2936
|
-
}
|
|
2937
|
-
if (tmp2 === "d/m/yyyy") {
|
|
2938
|
-
month = tmp[1];
|
|
2939
|
-
day = tmp[0];
|
|
2940
|
-
year = tmp[2];
|
|
2941
|
-
}
|
|
2942
|
-
if (tmp2 === "yyyy/dd/mm") {
|
|
2943
|
-
month = tmp[2];
|
|
2944
|
-
day = tmp[1];
|
|
2945
|
-
year = tmp[0];
|
|
2946
|
-
}
|
|
2947
|
-
if (tmp2 === "yyyy/d/m") {
|
|
2948
|
-
month = tmp[2];
|
|
2949
|
-
day = tmp[1];
|
|
2950
|
-
year = tmp[0];
|
|
2951
|
-
}
|
|
2952
|
-
if (tmp2 === "yyyy/mm/dd") {
|
|
2953
|
-
month = tmp[1];
|
|
2954
|
-
day = tmp[2];
|
|
2955
|
-
year = tmp[0];
|
|
2956
|
-
}
|
|
2957
|
-
if (tmp2 === "yyyy/m/d") {
|
|
2958
|
-
month = tmp[1];
|
|
2959
|
-
day = tmp[2];
|
|
2960
|
-
year = tmp[0];
|
|
2961
|
-
}
|
|
2962
|
-
if (tmp2 === "mm/dd/yy") {
|
|
2963
|
-
month = tmp[0];
|
|
2964
|
-
day = tmp[1];
|
|
2965
|
-
year = tmp[2];
|
|
2966
|
-
}
|
|
2967
|
-
if (tmp2 === "m/d/yy") {
|
|
2968
|
-
month = tmp[0];
|
|
2969
|
-
day = tmp[1];
|
|
2970
|
-
year = parseInt(tmp[2] ?? "0") + 1900;
|
|
2971
|
-
}
|
|
2972
|
-
if (tmp2 === "dd/mm/yy") {
|
|
2973
|
-
month = tmp[1];
|
|
2974
|
-
day = tmp[0];
|
|
2975
|
-
year = parseInt(tmp[2] ?? "0") + 1900;
|
|
2976
|
-
}
|
|
2977
|
-
if (tmp2 === "d/m/yy") {
|
|
2978
|
-
month = tmp[1];
|
|
2979
|
-
day = tmp[0];
|
|
2980
|
-
year = parseInt(tmp[2] ?? "0") + 1900;
|
|
2981
|
-
}
|
|
2982
|
-
if (tmp2 === "yy/dd/mm") {
|
|
2983
|
-
month = tmp[2];
|
|
2984
|
-
day = tmp[1];
|
|
2985
|
-
year = parseInt(tmp[0] ?? "0") + 1900;
|
|
2986
|
-
}
|
|
2987
|
-
if (tmp2 === "yy/d/m") {
|
|
2988
|
-
month = tmp[2];
|
|
2989
|
-
day = tmp[1];
|
|
2990
|
-
year = parseInt(tmp[0] ?? "0") + 1900;
|
|
2991
|
-
}
|
|
2992
|
-
if (tmp2 === "yy/mm/dd") {
|
|
2993
|
-
month = tmp[1];
|
|
2994
|
-
day = tmp[2];
|
|
2995
|
-
year = parseInt(tmp[0] ?? "0") + 1900;
|
|
2996
|
-
}
|
|
2997
|
-
if (tmp2 === "yy/m/d") {
|
|
2998
|
-
month = tmp[1];
|
|
2999
|
-
day = tmp[2];
|
|
3000
|
-
year = parseInt(tmp[0] ?? "0") + 1900;
|
|
3001
|
-
}
|
|
3002
|
-
}
|
|
3003
|
-
if (!this.isInt(year)) return false;
|
|
3004
|
-
if (!this.isInt(month)) return false;
|
|
3005
|
-
if (!this.isInt(day)) return false;
|
|
3006
|
-
const numYear = +(year ?? 0);
|
|
3007
|
-
const numMonth = +(month ?? 0);
|
|
3008
|
-
const numDay = +(day ?? 0);
|
|
3009
|
-
dt = new Date(numYear, numMonth - 1, numDay);
|
|
3010
|
-
dt.setFullYear(numYear);
|
|
3011
|
-
if (numMonth == null) return false;
|
|
3012
|
-
if (String(dt) === "Invalid Date") return false;
|
|
3013
|
-
if (dt.getMonth() + 1 !== numMonth || dt.getDate() !== numDay || dt.getFullYear() !== numYear) return false;
|
|
3014
|
-
if (retDate === true) return dt;
|
|
3015
|
-
else return true;
|
|
3226
|
+
return _isDate(val, format, retDate, this.settings);
|
|
3016
3227
|
}
|
|
3017
3228
|
isTime(val, retTime) {
|
|
3018
|
-
|
|
3019
|
-
let max;
|
|
3020
|
-
let strVal = String(val).toUpperCase();
|
|
3021
|
-
const am = strVal.indexOf("AM") >= 0;
|
|
3022
|
-
const pm = strVal.indexOf("PM") >= 0;
|
|
3023
|
-
const ampm = pm || am;
|
|
3024
|
-
if (ampm) max = 12;
|
|
3025
|
-
else max = 24;
|
|
3026
|
-
strVal = strVal.replace("AM", "").replace("PM", "").trim();
|
|
3027
|
-
const tmp = strVal.split(":");
|
|
3028
|
-
const tmp0 = tmp[0] ?? "", tmp1 = tmp[1] ?? "", tmp2 = tmp[2] ?? "";
|
|
3029
|
-
let h = parseInt(tmp0 || "0");
|
|
3030
|
-
const m = parseInt(tmp1 || "0"), s = parseInt(tmp2 || "0");
|
|
3031
|
-
if ((!ampm || tmp.length !== 1) && tmp.length !== 2 && tmp.length !== 3) {
|
|
3032
|
-
return false;
|
|
3033
|
-
}
|
|
3034
|
-
if (tmp0 === "" || h < 0 || h > max || !this.isInt(tmp0) || tmp0.length > 2) {
|
|
3035
|
-
return false;
|
|
3036
|
-
}
|
|
3037
|
-
if (tmp.length > 1 && (tmp1 === "" || m < 0 || m > 59 || !this.isInt(tmp1) || tmp1.length !== 2)) {
|
|
3038
|
-
return false;
|
|
3039
|
-
}
|
|
3040
|
-
if (tmp.length > 2 && (tmp2 === "" || s < 0 || s > 59 || !this.isInt(tmp2) || tmp2.length !== 2)) {
|
|
3041
|
-
return false;
|
|
3042
|
-
}
|
|
3043
|
-
if (!ampm && max === h && (m !== 0 || s !== 0)) {
|
|
3044
|
-
return false;
|
|
3045
|
-
}
|
|
3046
|
-
if (ampm && tmp.length === 1 && h === 0) {
|
|
3047
|
-
return false;
|
|
3048
|
-
}
|
|
3049
|
-
if (retTime === true) {
|
|
3050
|
-
if (pm && h !== 12) h += 12;
|
|
3051
|
-
if (am && h === 12) h += 12;
|
|
3052
|
-
return {
|
|
3053
|
-
hours: h,
|
|
3054
|
-
minutes: m,
|
|
3055
|
-
seconds: s
|
|
3056
|
-
};
|
|
3057
|
-
}
|
|
3058
|
-
return true;
|
|
3229
|
+
return _isTime(val, retTime);
|
|
3059
3230
|
}
|
|
3060
3231
|
isDateTime(val, format, retDate) {
|
|
3061
|
-
|
|
3062
|
-
if (retDate !== true) return true;
|
|
3063
|
-
return val;
|
|
3064
|
-
}
|
|
3065
|
-
const intVal = parseInt(String(val));
|
|
3066
|
-
if (intVal === val) {
|
|
3067
|
-
if (intVal < 0) return false;
|
|
3068
|
-
else if (retDate !== true) return true;
|
|
3069
|
-
else return new Date(intVal);
|
|
3070
|
-
}
|
|
3071
|
-
const strVal = String(val);
|
|
3072
|
-
const tmp = strVal.indexOf(" ");
|
|
3073
|
-
if (tmp < 0) {
|
|
3074
|
-
if (strVal.indexOf("T") < 0 || String(new Date(strVal)) == "Invalid Date") return false;
|
|
3075
|
-
else if (retDate !== true) return true;
|
|
3076
|
-
else return new Date(strVal);
|
|
3077
|
-
} else {
|
|
3078
|
-
if (format == null) format = this.settings.datetimeFormat;
|
|
3079
|
-
const formats = format.split("|");
|
|
3080
|
-
const values = [strVal.substr(0, tmp), strVal.substr(tmp).trim()];
|
|
3081
|
-
if (formats[0] != null) formats[0] = formats[0].trim();
|
|
3082
|
-
if (formats[1]) formats[1] = formats[1].trim();
|
|
3083
|
-
const tmp1 = this.isDate(values[0], formats[0], true);
|
|
3084
|
-
const tmp2 = this.isTime(values[1], true);
|
|
3085
|
-
if (tmp1 !== false && tmp2 !== false) {
|
|
3086
|
-
if (retDate !== true) return true;
|
|
3087
|
-
const dt1 = tmp1;
|
|
3088
|
-
const t2 = tmp2;
|
|
3089
|
-
dt1.setHours(t2.hours);
|
|
3090
|
-
dt1.setMinutes(t2.minutes);
|
|
3091
|
-
dt1.setSeconds(t2.seconds);
|
|
3092
|
-
return dt1;
|
|
3093
|
-
} else {
|
|
3094
|
-
return false;
|
|
3095
|
-
}
|
|
3096
|
-
}
|
|
3232
|
+
return _isDateTime(val, format, retDate, this.settings);
|
|
3097
3233
|
}
|
|
3098
3234
|
age(dateStr) {
|
|
3099
|
-
|
|
3100
|
-
if (dateStr === "" || dateStr == null) return "";
|
|
3101
|
-
if (dateStr instanceof Date) {
|
|
3102
|
-
d1 = dateStr;
|
|
3103
|
-
} else if (typeof dateStr === "number" || typeof dateStr === "string" && parseInt(dateStr) == dateStr && parseInt(dateStr) > 0) {
|
|
3104
|
-
d1 = new Date(parseInt(String(dateStr)));
|
|
3105
|
-
} else {
|
|
3106
|
-
d1 = new Date(String(dateStr));
|
|
3107
|
-
}
|
|
3108
|
-
if (String(d1) === "Invalid Date") return "";
|
|
3109
|
-
const d2 = /* @__PURE__ */ new Date();
|
|
3110
|
-
const sec = (d2.getTime() - d1.getTime()) / 1e3;
|
|
3111
|
-
let amount = 0;
|
|
3112
|
-
let type = "";
|
|
3113
|
-
if (sec < 0) {
|
|
3114
|
-
amount = 0;
|
|
3115
|
-
type = "sec";
|
|
3116
|
-
} else if (sec < 60) {
|
|
3117
|
-
amount = Math.floor(sec);
|
|
3118
|
-
type = "sec";
|
|
3119
|
-
if (sec < 0) {
|
|
3120
|
-
amount = 0;
|
|
3121
|
-
type = "sec";
|
|
3122
|
-
}
|
|
3123
|
-
} else if (sec < 60 * 60) {
|
|
3124
|
-
amount = Math.floor(sec / 60);
|
|
3125
|
-
type = "min";
|
|
3126
|
-
} else if (sec < 24 * 60 * 60) {
|
|
3127
|
-
amount = Math.floor(sec / 60 / 60);
|
|
3128
|
-
type = "hour";
|
|
3129
|
-
} else if (sec < 30 * 24 * 60 * 60) {
|
|
3130
|
-
amount = Math.floor(sec / 24 / 60 / 60);
|
|
3131
|
-
type = "day";
|
|
3132
|
-
} else if (sec < 365 * 24 * 60 * 60) {
|
|
3133
|
-
amount = Math.floor(sec / 30 / 24 / 60 / 60 * 10) / 10;
|
|
3134
|
-
type = "month";
|
|
3135
|
-
} else if (sec < 365 * 4 * 24 * 60 * 60) {
|
|
3136
|
-
amount = Math.floor(sec / 365 / 24 / 60 / 60 * 10) / 10;
|
|
3137
|
-
type = "year";
|
|
3138
|
-
} else if (sec >= 365 * 4 * 24 * 60 * 60) {
|
|
3139
|
-
amount = Math.floor(sec / 365.25 / 24 / 60 / 60 * 10) / 10;
|
|
3140
|
-
type = "year";
|
|
3141
|
-
}
|
|
3142
|
-
return amount + " " + type + (amount > 1 ? "s" : "");
|
|
3235
|
+
return _age(dateStr);
|
|
3143
3236
|
}
|
|
3144
3237
|
interval(value) {
|
|
3145
|
-
|
|
3146
|
-
if (value < 100) {
|
|
3147
|
-
ret = "< 0.01 sec";
|
|
3148
|
-
} else if (value < 1e3) {
|
|
3149
|
-
ret = Math.floor(value / 10) / 100 + " sec";
|
|
3150
|
-
} else if (value < 1e4) {
|
|
3151
|
-
ret = Math.floor(value / 100) / 10 + " sec";
|
|
3152
|
-
} else if (value < 6e4) {
|
|
3153
|
-
ret = Math.floor(value / 1e3) + " secs";
|
|
3154
|
-
} else if (value < 36e5) {
|
|
3155
|
-
ret = Math.floor(value / 6e4) + " mins";
|
|
3156
|
-
} else if (value < 864e5) {
|
|
3157
|
-
ret = Math.floor(value / 36e5 * 10) / 10 + " hours";
|
|
3158
|
-
} else if (value < 2628e6) {
|
|
3159
|
-
ret = Math.floor(value / 864e5 * 10) / 10 + " days";
|
|
3160
|
-
} else if (value < 31536e6) {
|
|
3161
|
-
ret = Math.floor(value / 2628e6 * 10) / 10 + " months";
|
|
3162
|
-
} else {
|
|
3163
|
-
ret = Math.floor(value / 31536e5) / 10 + " years";
|
|
3164
|
-
}
|
|
3165
|
-
return ret;
|
|
3238
|
+
return _interval(value);
|
|
3166
3239
|
}
|
|
3167
3240
|
date(dateStr) {
|
|
3168
3241
|
if (dateStr === "" || dateStr == null || typeof dateStr === "object" && !dateStr.getMonth) return "";
|
|
@@ -3205,60 +3278,13 @@ var Utils = class {
|
|
|
3205
3278
|
return parseFloat(String(val)).toLocaleString(this.settings.locale, options);
|
|
3206
3279
|
}
|
|
3207
3280
|
formatDate(dateStr, format) {
|
|
3208
|
-
|
|
3209
|
-
if (dateStr === "" || dateStr == null || typeof dateStr === "object" && !dateStr.getMonth) return "";
|
|
3210
|
-
let dt = new Date(dateStr);
|
|
3211
|
-
if (this.isInt(dateStr)) dt = new Date(Number(dateStr));
|
|
3212
|
-
if (String(dt) === "Invalid Date") return "";
|
|
3213
|
-
const year = dt.getFullYear();
|
|
3214
|
-
const month = dt.getMonth();
|
|
3215
|
-
const date = dt.getDate();
|
|
3216
|
-
return format.toLowerCase().replace("month", this.settings.fullmonths[month] ?? "").replace("mon", this.settings.shortmonths[month] ?? "").replace(/yyyy/g, ("000" + year).slice(-4)).replace(/yyy/g, ("000" + year).slice(-4)).replace(/yy/g, ("0" + year).slice(-2)).replace(/(^|[^a-z$])y/g, "$1" + year).replace(/mm/g, ("0" + (month + 1)).slice(-2)).replace(/dd/g, ("0" + date).slice(-2)).replace(/th/g, date == 1 ? "st" : "th").replace(/th/g, date == 2 ? "nd" : "th").replace(/th/g, date == 3 ? "rd" : "th").replace(/(^|[^a-z$])m/g, "$1" + (month + 1)).replace(/(^|[^a-z$])d/g, "$1" + date);
|
|
3281
|
+
return _formatDate(dateStr, format, this.settings);
|
|
3217
3282
|
}
|
|
3218
3283
|
formatTime(dateStr, format) {
|
|
3219
|
-
|
|
3220
|
-
if (dateStr === "" || dateStr == null || typeof dateStr === "object" && !dateStr.getMonth) return "";
|
|
3221
|
-
let dt = new Date(dateStr);
|
|
3222
|
-
if (this.isInt(dateStr)) dt = new Date(Number(dateStr));
|
|
3223
|
-
if (this.isTime(dateStr)) {
|
|
3224
|
-
const tmp = this.isTime(dateStr, true);
|
|
3225
|
-
dt = /* @__PURE__ */ new Date();
|
|
3226
|
-
dt.setHours(tmp.hours);
|
|
3227
|
-
dt.setMinutes(tmp.minutes);
|
|
3228
|
-
}
|
|
3229
|
-
if (String(dt) === "Invalid Date") return "";
|
|
3230
|
-
if (format == "h12") format = "hh:mi pm";
|
|
3231
|
-
let type = "am";
|
|
3232
|
-
let hour = dt.getHours();
|
|
3233
|
-
const h24 = dt.getHours();
|
|
3234
|
-
let min = dt.getMinutes();
|
|
3235
|
-
let sec = dt.getSeconds();
|
|
3236
|
-
if (min < 10) min = "0" + min;
|
|
3237
|
-
if (sec < 10) sec = "0" + sec;
|
|
3238
|
-
if (format.indexOf("am") !== -1 || format.indexOf("pm") !== -1) {
|
|
3239
|
-
if (hour >= 12) type = "pm";
|
|
3240
|
-
if (hour > 12) hour = hour - 12;
|
|
3241
|
-
if (hour === 0) hour = 12;
|
|
3242
|
-
}
|
|
3243
|
-
const hourStr = String(hour);
|
|
3244
|
-
const minStr = String(min);
|
|
3245
|
-
const secStr = String(sec);
|
|
3246
|
-
const h24Str = String(h24);
|
|
3247
|
-
return format.toLowerCase().replace("am", type).replace("pm", type).replace("hhh", Number(hour) < 10 ? "0" + hourStr : hourStr).replace("hh24", h24 < 10 ? "0" + h24Str : h24Str).replace("h24", h24Str).replace("hh", hourStr).replace("mm", minStr).replace("mi", minStr).replace("ss", secStr).replace(/(^|[^a-z$])h/g, "$1" + hourStr).replace(/(^|[^a-z$])m/g, "$1" + minStr).replace(/(^|[^a-z$])s/g, "$1" + secStr);
|
|
3284
|
+
return _formatTime(dateStr, format, this.settings);
|
|
3248
3285
|
}
|
|
3249
3286
|
formatDateTime(dateStr, format) {
|
|
3250
|
-
|
|
3251
|
-
if (dateStr === "" || dateStr == null || typeof dateStr === "object" && !dateStr.getMonth) return "";
|
|
3252
|
-
if (typeof format !== "string") {
|
|
3253
|
-
fmt = [this.settings.dateFormat, this.settings.timeFormat];
|
|
3254
|
-
} else {
|
|
3255
|
-
fmt = format.split("|");
|
|
3256
|
-
if (fmt[0] != null) fmt[0] = fmt[0].trim();
|
|
3257
|
-
fmt[1] = fmt.length > 1 ? (fmt[1] ?? "").trim() : this.settings.timeFormat;
|
|
3258
|
-
}
|
|
3259
|
-
if (fmt[1] === "h12") fmt[1] = "h:m pm";
|
|
3260
|
-
if (fmt[1] === "h24") fmt[1] = "h24:m";
|
|
3261
|
-
return this.formatDate(dateStr, fmt[0]) + " " + this.formatTime(dateStr, fmt[1]);
|
|
3287
|
+
return _formatDateTime(dateStr, format, this.settings);
|
|
3262
3288
|
}
|
|
3263
3289
|
stripSpaces(html) {
|
|
3264
3290
|
return stripSpaces(html);
|