@davidkhala/crypto
Version:
## Limitation - node-forge doesn't support ECDSA yet - https://github.com/digitalbazaar/forge/issues/116 - https://github.com/digitalbazaar/forge/issues/532 - https://github.com/digitalbazaar/forge/issues/671 - https://github.com/digitalbazaar/for
21 lines (18 loc) • 429 B
JavaScript
// https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.5.1
// YYMMDDHHMMSSZ
import dateFormat from 'date-format';
const dateFormatMask = 'yyMMddhhmmssZ';
export class X509Time {
/**
* @param {Date|number} [date]
*/
constructor(date = new Date()) {
if (typeof date === 'number') {
date = new Date(date);
}
Object.assign(this, {date});
}
toString() {
return dateFormat(dateFormatMask, this.date);
}
}