prlg-ui 1.2.7 → 1.3.1
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.d.ts +2 -0
- package/dist/prlg-ui.cjs.js +1 -1
- package/dist/prlg-ui.css +1 -1
- package/dist/prlg-ui.es.js +2 -1
- package/dist/utils/date.util.ts +6 -5
- package/dist/utils/eventBus.util.ts +2 -0
- package/dist/utils/index.cjs.js +1 -1
- package/dist/utils/index.es.js +2250 -402
- package/dist/utils/parseDate.util.ts +41 -0
- package/package.json +2 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
function parseDurationToSeconds(duration: string): number {
|
|
2
|
+
const regex = /^(\d+)(s|m|h|d|day|month|year)$/;
|
|
3
|
+
const match = duration.match(regex);
|
|
4
|
+
|
|
5
|
+
if (!match) {
|
|
6
|
+
throw new Error('Invalid duration format. Use formats like 30d, 1m, 1h, 1day, 1month, 1year');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const value = parseInt(match[1], 10);
|
|
10
|
+
const unit = match[2];
|
|
11
|
+
|
|
12
|
+
switch (unit) {
|
|
13
|
+
case 's':
|
|
14
|
+
return value; // seconds
|
|
15
|
+
case 'm':
|
|
16
|
+
return value * 60; // minutes
|
|
17
|
+
case 'h':
|
|
18
|
+
return value * 3600; // hours
|
|
19
|
+
case 'd':
|
|
20
|
+
case 'day':
|
|
21
|
+
return value * 86400; // days
|
|
22
|
+
case 'month':
|
|
23
|
+
return value * 2592000; // months (30 days)
|
|
24
|
+
case 'year':
|
|
25
|
+
return value * 31536000; // years (365 days)
|
|
26
|
+
default:
|
|
27
|
+
throw new Error('Unsupported time unit');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default parseDurationToSeconds;
|
|
32
|
+
|
|
33
|
+
/** Примеры использования */
|
|
34
|
+
/** example
|
|
35
|
+
console.log(parseDurationToSeconds('30d')); // 2592000
|
|
36
|
+
console.log(parseDurationToSeconds('1m')); // 60
|
|
37
|
+
console.log(parseDurationToSeconds('1h')); // 3600
|
|
38
|
+
console.log(parseDurationToSeconds('1day')); // 86400
|
|
39
|
+
console.log(parseDurationToSeconds('1month')); // 2592000
|
|
40
|
+
console.log(parseDurationToSeconds('1year')); // 31536000
|
|
41
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prlg-ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/prlg-ui.umd.js",
|
|
7
7
|
"module": "dist/prlg-ui.es.js",
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@floating-ui/dom": "^1.7.2",
|
|
77
|
+
"date-fns": "^4.1.0",
|
|
77
78
|
"vue": "^3.5.17"
|
|
78
79
|
}
|
|
79
80
|
}
|