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.
@@ -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.2.7",
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
  }