valgen 5.17.0 → 5.17.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/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
-
### [v5.17.
|
|
3
|
+
### [v5.17.1](https://github.com/panates/valgen/compare/v5.17.0...v5.17.1) -
|
|
4
|
+
|
|
5
|
+
#### 🪲 Fixes
|
|
6
|
+
|
|
7
|
+
- fix: isDate milliseconds padding @Eray Hanoğlu
|
|
8
|
+
|
|
9
|
+
### [v5.17.0](https://github.com/panates/valgen/compare/v5.16.0...v5.17.0) - 24 July 2025
|
|
4
10
|
|
|
5
11
|
#### 🪲 Fixes
|
|
6
12
|
|
|
@@ -71,13 +71,13 @@ function coerceDateString(input, precision) {
|
|
|
71
71
|
if (input instanceof Date || typeof input === 'number') {
|
|
72
72
|
const d = typeof input === 'number' ? new Date(input) : input;
|
|
73
73
|
dateParts = [
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
String(d.getMilliseconds()),
|
|
74
|
+
String(d.getFullYear()).padStart(4, '0'),
|
|
75
|
+
String(d.getMonth() + 1).padStart(2, '0'),
|
|
76
|
+
String(d.getDate()).padStart(2, '0'),
|
|
77
|
+
String(d.getHours()).padStart(2, '0'),
|
|
78
|
+
String(d.getMinutes()).padStart(2, '0'),
|
|
79
|
+
String(d.getSeconds()).padStart(2, '0'),
|
|
80
|
+
String(d.getMilliseconds()).padStart(3, '0'),
|
|
81
81
|
];
|
|
82
82
|
}
|
|
83
83
|
else if (typeof input === 'string') {
|
|
@@ -131,24 +131,6 @@ const PRECISION_INDEX = {
|
|
|
131
131
|
ms: 7,
|
|
132
132
|
tz: 8,
|
|
133
133
|
};
|
|
134
|
-
/**
|
|
135
|
-
* Pads a string to the specified length
|
|
136
|
-
* @param value - The string to pad
|
|
137
|
-
* @param len - The desired total length of the resulting string
|
|
138
|
-
* @param padChar - The character to pad with (defaults to '0')
|
|
139
|
-
* @returns The padded string
|
|
140
|
-
*/
|
|
141
|
-
function padString(value, len, padChar = '0') {
|
|
142
|
-
// Convert value to string if it's a number
|
|
143
|
-
const str = String(value);
|
|
144
|
-
// Return original string if it's already longer or equal to target length
|
|
145
|
-
if (str.length >= len) {
|
|
146
|
-
return str;
|
|
147
|
-
}
|
|
148
|
-
// Create padding and concatenate with original string
|
|
149
|
-
const padding = padChar.repeat(len - str.length);
|
|
150
|
-
return padding + str;
|
|
151
|
-
}
|
|
152
134
|
function setPrecision(d, precision) {
|
|
153
135
|
switch (precision) {
|
|
154
136
|
case 'year': {
|
|
@@ -66,13 +66,13 @@ function coerceDateString(input, precision) {
|
|
|
66
66
|
if (input instanceof Date || typeof input === 'number') {
|
|
67
67
|
const d = typeof input === 'number' ? new Date(input) : input;
|
|
68
68
|
dateParts = [
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
String(d.getMilliseconds()),
|
|
69
|
+
String(d.getFullYear()).padStart(4, '0'),
|
|
70
|
+
String(d.getMonth() + 1).padStart(2, '0'),
|
|
71
|
+
String(d.getDate()).padStart(2, '0'),
|
|
72
|
+
String(d.getHours()).padStart(2, '0'),
|
|
73
|
+
String(d.getMinutes()).padStart(2, '0'),
|
|
74
|
+
String(d.getSeconds()).padStart(2, '0'),
|
|
75
|
+
String(d.getMilliseconds()).padStart(3, '0'),
|
|
76
76
|
];
|
|
77
77
|
}
|
|
78
78
|
else if (typeof input === 'string') {
|
|
@@ -126,24 +126,6 @@ const PRECISION_INDEX = {
|
|
|
126
126
|
ms: 7,
|
|
127
127
|
tz: 8,
|
|
128
128
|
};
|
|
129
|
-
/**
|
|
130
|
-
* Pads a string to the specified length
|
|
131
|
-
* @param value - The string to pad
|
|
132
|
-
* @param len - The desired total length of the resulting string
|
|
133
|
-
* @param padChar - The character to pad with (defaults to '0')
|
|
134
|
-
* @returns The padded string
|
|
135
|
-
*/
|
|
136
|
-
function padString(value, len, padChar = '0') {
|
|
137
|
-
// Convert value to string if it's a number
|
|
138
|
-
const str = String(value);
|
|
139
|
-
// Return original string if it's already longer or equal to target length
|
|
140
|
-
if (str.length >= len) {
|
|
141
|
-
return str;
|
|
142
|
-
}
|
|
143
|
-
// Create padding and concatenate with original string
|
|
144
|
-
const padding = padChar.repeat(len - str.length);
|
|
145
|
-
return padding + str;
|
|
146
|
-
}
|
|
147
129
|
function setPrecision(d, precision) {
|
|
148
130
|
switch (precision) {
|
|
149
131
|
case 'year': {
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valgen",
|
|
3
3
|
"description": "Fast runtime type validator, converter and io (encoding/decoding) library",
|
|
4
|
-
"version": "5.17.
|
|
4
|
+
"version": "5.17.1",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@browsery/validator": "^13.12.0-r3",
|
|
9
|
-
"@js-temporal/polyfill": "^0.5.1",
|
|
10
9
|
"date-fns": "^4.1.0",
|
|
11
10
|
"reflect-metadata": "^0.2.2",
|
|
12
11
|
"ts-gems": "^3.11.3",
|