asn1-ts 9.0.0 → 9.0.2
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/codecs/x690/encoders/encodeDate.mjs +1 -1
- package/dist/codecs/x690/encoders/encodeDateTime.mjs +1 -1
- package/dist/codecs/x690/encoders/encodeGeneralizedTime.mjs +1 -1
- package/dist/codecs/x690/encoders/encodeTimeOfDay.mjs +3 -1
- package/dist/codecs/x690/encoders/encodeUTCTime.mjs +1 -1
- package/package.json +2 -2
|
@@ -5,7 +5,7 @@ export default function encodeDate(date) {
|
|
|
5
5
|
throw new errors.ASN1Error(`The DATE ${date.toISOString()} may not be encoded, because the `
|
|
6
6
|
+ "year must be greater than 1581 and less than 10000.");
|
|
7
7
|
}
|
|
8
|
-
return convertTextToBytes(date.getFullYear().toString()
|
|
8
|
+
return convertTextToBytes(date.getFullYear().toString().padStart(4, "0")
|
|
9
9
|
+ (date.getMonth() + 1).toString().padStart(2, "0")
|
|
10
10
|
+ date.getDate().toString().padStart(2, "0"));
|
|
11
11
|
}
|
|
@@ -5,7 +5,7 @@ export default function encodeDateTime(value) {
|
|
|
5
5
|
throw new errors.ASN1Error(`The DATE ${value.toISOString()} may not be encoded, because the `
|
|
6
6
|
+ "year must be greater than 1581 and less than 10000.");
|
|
7
7
|
}
|
|
8
|
-
return convertTextToBytes(value.getFullYear().toString()
|
|
8
|
+
return convertTextToBytes(value.getFullYear().toString().padStart(4, "0")
|
|
9
9
|
+ (value.getMonth() + 1).toString().padStart(2, "0")
|
|
10
10
|
+ value.getDate().toString().padStart(2, "0")
|
|
11
11
|
+ value.getHours().toString().padStart(2, "0")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import convertTextToBytes from "../../../utils/convertTextToBytes.mjs";
|
|
2
2
|
export default function encodeGeneralizedTime(value) {
|
|
3
|
-
const year = value.getUTCFullYear().toString();
|
|
3
|
+
const year = value.getUTCFullYear().toString().padStart(4, "0");
|
|
4
4
|
const month = (value.getUTCMonth() + 1).toString().padStart(2, "0");
|
|
5
5
|
const day = value.getUTCDate().toString().padStart(2, "0");
|
|
6
6
|
const hour = value.getUTCHours().toString().padStart(2, "0");
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import convertTextToBytes from "../../../utils/convertTextToBytes.mjs";
|
|
2
2
|
export default function encodeTimeOfDay(time) {
|
|
3
|
-
return convertTextToBytes(
|
|
3
|
+
return convertTextToBytes(time.getHours().toString().padStart(2, "0")
|
|
4
|
+
+ time.getMinutes().toString().padStart(2, "0")
|
|
5
|
+
+ time.getSeconds().toString().padStart(2, "0"));
|
|
4
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import convertTextToBytes from "../../../utils/convertTextToBytes.mjs";
|
|
2
2
|
export default function encodeUTCTime(value) {
|
|
3
3
|
let year = value.getUTCFullYear().toString();
|
|
4
|
-
year = (year.substring(year.length - 2, year.length));
|
|
4
|
+
year = (year.substring(year.length - 2, year.length)).padStart(2, "0");
|
|
5
5
|
const month = (value.getUTCMonth() + 1).toString().padStart(2, "0");
|
|
6
6
|
const day = value.getUTCDate().toString().padStart(2, "0");
|
|
7
7
|
const hour = value.getUTCHours().toString().padStart(2, "0");
|
package/package.json
CHANGED