@opengeoweb/shared 9.7.0 → 9.8.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/index.esm.js
CHANGED
|
@@ -3674,6 +3674,27 @@ var unix = function unix(date) {
|
|
|
3674
3674
|
var fromUnix = function fromUnix(unixTime) {
|
|
3675
3675
|
return fromUnixTime(unixTime);
|
|
3676
3676
|
};
|
|
3677
|
+
var parseCustomDateString = function parseCustomDateString(dateStr) {
|
|
3678
|
+
var customFormatRegex = /^\d{12}$/;
|
|
3679
|
+
var customFormatWithTRegex = /^\d{8}T\d{6}$/;
|
|
3680
|
+
if (customFormatRegex.test(dateStr)) {
|
|
3681
|
+
var year = parseInt(dateStr.substring(0, 4), 10);
|
|
3682
|
+
var month = parseInt(dateStr.substring(4, 6), 10) - 1;
|
|
3683
|
+
var day = parseInt(dateStr.substring(6, 8), 10);
|
|
3684
|
+
var hour = parseInt(dateStr.substring(8, 10), 10);
|
|
3685
|
+
var minute = parseInt(dateStr.substring(10, 12), 10);
|
|
3686
|
+
return new Date(Date.UTC(year, month, day, hour, minute));
|
|
3687
|
+
}
|
|
3688
|
+
if (customFormatWithTRegex.test(dateStr)) {
|
|
3689
|
+
var _year = parseInt(dateStr.substring(0, 4), 10);
|
|
3690
|
+
var _month = parseInt(dateStr.substring(4, 6), 10) - 1;
|
|
3691
|
+
var _day = parseInt(dateStr.substring(6, 8), 10);
|
|
3692
|
+
var _hour = parseInt(dateStr.substring(9, 11), 10);
|
|
3693
|
+
var _minute = parseInt(dateStr.substring(11, 13), 10);
|
|
3694
|
+
return new Date(Date.UTC(_year, _month, _day, _hour, _minute));
|
|
3695
|
+
}
|
|
3696
|
+
return new Date(dateStr);
|
|
3697
|
+
};
|
|
3677
3698
|
/**
|
|
3678
3699
|
* Set date values to a given date (by default it is assumed you are passing the new values in UTC).
|
|
3679
3700
|
* @param date - the dater to be changed
|
|
@@ -3746,6 +3767,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
3746
3767
|
isValid: isValid,
|
|
3747
3768
|
unix: unix,
|
|
3748
3769
|
fromUnix: fromUnix,
|
|
3770
|
+
parseCustomDateString: parseCustomDateString,
|
|
3749
3771
|
set: set,
|
|
3750
3772
|
isEqual: isEqual,
|
|
3751
3773
|
startOfDay: startOfDay,
|
package/package.json
CHANGED
|
@@ -212,6 +212,7 @@ export declare const unix: (date: Date | number) => number;
|
|
|
212
212
|
* @returns the timestamp
|
|
213
213
|
*/
|
|
214
214
|
export declare const fromUnix: (unixTime: number) => Date;
|
|
215
|
+
export declare const parseCustomDateString: (dateStr: string) => Date;
|
|
215
216
|
/**
|
|
216
217
|
* Set date values to a given date (by default it is assumed you are passing the new values in UTC).
|
|
217
218
|
* @param date - the dater to be changed
|