MCPcopy
hub / github.com/socketio/socket.io / _dateToAsn1

Function _dateToAsn1

packages/engine.io/test/util.mjs:71–88  ·  view source on GitHub ↗

* Converts a Date object to ASN.1 * Handles the different format before and after 1st January 2050 * * @param {Date} date date object. * * @return the ASN.1 object representing the date.

(date)

Source from the content-addressed store, hash-verified

69 * @return the ASN.1 object representing the date.
70 */
71function _dateToAsn1(date) {
72 // eslint-disable-next-line camelcase
73 if (date >= jan_1_1950 && date < jan_1_2050) {
74 return asn1.create(
75 asn1.Class.UNIVERSAL,
76 asn1.Type.UTCTIME,
77 false,
78 asn1.dateToUtcTime(date)
79 )
80 } else {
81 return asn1.create(
82 asn1.Class.UNIVERSAL,
83 asn1.Type.GENERALIZEDTIME,
84 false,
85 asn1.dateToGeneralizedTime(date)
86 )
87 }
88}
89
90// taken from node-forge almost not modified
91/**

Callers 1

getTBSCertificateFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected