puvox-library 1.0.24 → 1.0.25
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/library_standard.js +23 -12
- package/package.json +1 -1
package/library_standard.js
CHANGED
@@ -828,30 +828,29 @@ const puvox_library =
|
|
828
828
|
let finalStr = (withT ? str.replace(' ', 'T') : str);
|
829
829
|
return withMS ? finalStr : finalStr.split('.')[0]; //2022-07-09 19:25:00.276
|
830
830
|
},
|
831
|
-
// in some langs, the date object has distinctions, so the two below needs separated methods
|
832
|
-
StringToDatetimeUtc(str, format, culture) { return new Date(str); },
|
833
|
-
StringToDatetimeLocal(str, format, culture) { return new Date(str); },
|
834
|
-
|
831
|
+
// in some langs, the date object has distinctions, so the two below needs separated methods. However, the "date" object returned from them, are same, just the representation can be local or UTC depending user.
|
832
|
+
StringToDatetimeUtc(str, format, culture) { return new Date(str); },
|
833
|
+
StringToDatetimeLocal(str, format, culture) { return new Date(str); },
|
834
|
+
DatetimeUtc() {
|
835
835
|
var now = new Date();
|
836
836
|
var utc = new Date(now.getTime()); // + now.getTimezoneOffset() * 60000 is not needed !!!!!!
|
837
837
|
return utc;
|
838
|
-
},
|
839
|
-
UtcDatetimeFrom(dt) { }, // DateTime
|
838
|
+
}, UtcDatetime() { return this.DatetimeUtc(); },
|
840
839
|
// UTC
|
841
|
-
|
840
|
+
TimestampUtc() {
|
842
841
|
return Math.floor(new Date().getTime());
|
843
|
-
},
|
842
|
+
}, UtcTimestamp() { return this.TimestampUtc(); },
|
844
843
|
//i.e. input: "2021-03-08 11:59:00" | output : 1650000000000 (milliseconds)
|
845
844
|
// [DONT CHANGE THIS FUNC, I'VE REVISED]
|
846
|
-
|
845
|
+
DatetimeToTimestampUtc(dt) {
|
847
846
|
let offset = this.getOffsetFromUtc();
|
848
847
|
return ((((new Date( dt )).getTime()) / 1000) + 14400 - offset * 60* 60) * 1000;
|
849
|
-
},
|
850
|
-
|
848
|
+
}, UtcTimestampFrom(dt) { return this.DatetimeToTimestampUtc(dt); },
|
849
|
+
TimestampUtcToDatetimeUtc(ts) {
|
851
850
|
var d = new Date(ts);
|
852
851
|
d.setHours(d.getHours());
|
853
852
|
return d;
|
854
|
-
},
|
853
|
+
}, UtcTimestampToUtcDatetime(ts) { return this.TimestampUtcToDatetimeUtc(ts); },
|
855
854
|
// shorthands
|
856
855
|
MaxDate(d1, d2, d3=null) {},
|
857
856
|
MinDate(d1, d2, d3=null) {},
|
@@ -2407,6 +2406,18 @@ const puvox_library =
|
|
2407
2406
|
};
|
2408
2407
|
},
|
2409
2408
|
|
2409
|
+
compare(a, b, operator) {
|
2410
|
+
if(operator === '==') return a == b;
|
2411
|
+
else if (operator === '===') return a === b;
|
2412
|
+
else if (operator === '!=') return a != b;
|
2413
|
+
else if (operator === '!==') return a !== b;
|
2414
|
+
else if (operator === '>') return a > b;
|
2415
|
+
else if (operator === '>=') return a >= b;
|
2416
|
+
else if (operator === '<') return a < b;
|
2417
|
+
else if (operator === '<=') return a <= b;
|
2418
|
+
else throw "Unknown operator";
|
2419
|
+
},
|
2420
|
+
|
2410
2421
|
// random NUMBER or STRINGS
|
2411
2422
|
RandomNum(maxNum) { return Math.floor((Math.random() * maxNum) + 1); },
|
2412
2423
|
|