* 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)
| 69 | * @return the ASN.1 object representing the date. |
| 70 | */ |
| 71 | function _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 | /** |