define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var _PdfX509Time = (function () {
function _PdfX509Time(time) {
this._time = time;
}
_PdfX509Time.prototype._getUniversalTime = function () {
if (this._time._getTagNumber() === 23) {
var val = this._time._getValue();
if (typeof val === 'string') {
return val.trim();
}
if (val instanceof Uint8Array) {
var charCodes = [];
for (var i = 0; i < val.length; i++) {
charCodes.push(val[i]);
}
return String.fromCharCode.apply(null, charCodes).trim();
}
}
return undefined;
};
_PdfX509Time.prototype._toDate = function () {
var str = this._getUniversalTime();
if (str) {
var m = str.match(/^(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z$/);
if (!m) {
m = str.match(/^(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z$/);
}
if (m) {
var year = parseInt(m[1], 10);
year += (year < 50) ? 2000 : 1900;
var month = parseInt(m[2], 10) - 1;
var day = parseInt(m[3], 10);
var hour = parseInt(m[4], 10);
var minute = parseInt(m[5], 10);
var second = m.length > 6 && typeof m[6] !== 'undefined' ? parseInt(m[6], 10) : 0;
return new Date(Date.UTC(year, month, day, hour, minute, second));
}
}
return undefined;
};
return _PdfX509Time;
}());
exports._PdfX509Time = _PdfX509Time;
});
|