int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)
{
    char *v;
    int gmt = 0;
    int i;
    int y = 0, M = 0, d = 0, h = 0, m = 0, s = 0;
    char *f = NULL;
    int f_len = 0;
    i = tm->length;
    v = (char *)tm->data;
    if (i < 12)
        goto err;
    if (v[i - 1] == 'Z')
        gmt = 1;
    for (i = 0; i < 12; i++)
        if ((v[i] > '9') || (v[i] < '0'))
            goto err;
    y = (v[0] - '0') * 1000 + (v[1] - '0') * 100
        + (v[2] - '0') * 10 + (v[3] - '0');
    M = (v[4] - '0') * 10 + (v[5] - '0');
    if ((M > 12) || (M < 1))
        goto err;
    d = (v[6] - '0') * 10 + (v[7] - '0');
    h = (v[8] - '0') * 10 + (v[9] - '0');
    m = (v[10] - '0') * 10 + (v[11] - '0');
    if (tm->length >= 14 &&
        (v[12] >= '0') && (v[12] <= '9') &&
        (v[13] >= '0') && (v[13] <= '9')) {
        s = (v[12] - '0') * 10 + (v[13] - '0');
        if (tm->length >= 15 && v[14] == '.') {
            int l = tm->length;
            f = &v[14];
            f_len = 1;
            while (14 + f_len < l && f[f_len] >= '0' && f[f_len] <= '9')
                ++f_len;
        }
    }
    if (BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s",
                   _asn1_mon[M - 1], d, h, m, s, f_len, f, y,
                   (gmt) ? " GMT" : "") <= 0)
        return (0);
    else
        return (1);
 err:
    BIO_write(bp, "Bad time value", 14);
    return (0);
}
['static void timestamp_print(BIO *out, uint64_t timestamp)\n{\n    ASN1_GENERALIZEDTIME *gen;\n    char genstr[20];\n    gen = ASN1_GENERALIZEDTIME_new();\n    ASN1_GENERALIZEDTIME_adj(gen, (time_t)0,\n                             (int)(timestamp / 86400000),\n                             (timestamp % 86400000) / 1000);\n    BIO_snprintf(genstr, sizeof(genstr), "%.14s.%03dZ",\n                 ASN1_STRING_data(gen), (unsigned int)(timestamp % 1000));\n    ASN1_GENERALIZEDTIME_set_string(gen, genstr);\n    ASN1_GENERALIZEDTIME_print(out, gen);\n    ASN1_GENERALIZEDTIME_free(gen);\n}', 'ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,\n                                               time_t t, int offset_day,\n                                               long offset_sec)\n{\n    char *p;\n    struct tm *ts;\n    struct tm data;\n    size_t len = 20;\n    if (s == NULL)\n        s = ASN1_GENERALIZEDTIME_new();\n    if (s == NULL)\n        return (NULL);\n    ts = OPENSSL_gmtime(&t, &data);\n    if (ts == NULL)\n        return (NULL);\n    if (offset_day || offset_sec) {\n        if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))\n            return NULL;\n    }\n    p = (char *)s->data;\n    if ((p == NULL) || ((size_t)s->length < len)) {\n        p = OPENSSL_malloc(len);\n        if (p == NULL) {\n            ASN1err(ASN1_F_ASN1_GENERALIZEDTIME_ADJ, ERR_R_MALLOC_FAILURE);\n            return (NULL);\n        }\n        OPENSSL_free(s->data);\n        s->data = (unsigned char *)p;\n    }\n    BIO_snprintf(p, len, "%04d%02d%02d%02d%02d%02dZ", ts->tm_year + 1900,\n                 ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min,\n                 ts->tm_sec);\n    s->length = strlen(p);\n    s->type = V_ASN1_GENERALIZEDTIME;\n#ifdef CHARSET_EBCDIC_not\n    ebcdic2ascii(s->data, s->data, s->length);\n#endif\n    return (s);\n}', 'int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str)\n{\n    ASN1_GENERALIZEDTIME t;\n    t.type = V_ASN1_GENERALIZEDTIME;\n    t.length = strlen(str);\n    t.data = (unsigned char *)str;\n    if (ASN1_GENERALIZEDTIME_check(&t)) {\n        if (s != NULL) {\n            if (!ASN1_STRING_set((ASN1_STRING *)s,\n                                 (unsigned char *)str, t.length))\n                return 0;\n            s->type = V_ASN1_GENERALIZEDTIME;\n        }\n        return (1);\n    } else\n        return (0);\n}', 'int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)\n{\n    char *v;\n    int gmt = 0;\n    int i;\n    int y = 0, M = 0, d = 0, h = 0, m = 0, s = 0;\n    char *f = NULL;\n    int f_len = 0;\n    i = tm->length;\n    v = (char *)tm->data;\n    if (i < 12)\n        goto err;\n    if (v[i - 1] == \'Z\')\n        gmt = 1;\n    for (i = 0; i < 12; i++)\n        if ((v[i] > \'9\') || (v[i] < \'0\'))\n            goto err;\n    y = (v[0] - \'0\') * 1000 + (v[1] - \'0\') * 100\n        + (v[2] - \'0\') * 10 + (v[3] - \'0\');\n    M = (v[4] - \'0\') * 10 + (v[5] - \'0\');\n    if ((M > 12) || (M < 1))\n        goto err;\n    d = (v[6] - \'0\') * 10 + (v[7] - \'0\');\n    h = (v[8] - \'0\') * 10 + (v[9] - \'0\');\n    m = (v[10] - \'0\') * 10 + (v[11] - \'0\');\n    if (tm->length >= 14 &&\n        (v[12] >= \'0\') && (v[12] <= \'9\') &&\n        (v[13] >= \'0\') && (v[13] <= \'9\')) {\n        s = (v[12] - \'0\') * 10 + (v[13] - \'0\');\n        if (tm->length >= 15 && v[14] == \'.\') {\n            int l = tm->length;\n            f = &v[14];\n            f_len = 1;\n            while (14 + f_len < l && f[f_len] >= \'0\' && f[f_len] <= \'9\')\n                ++f_len;\n        }\n    }\n    if (BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s",\n                   _asn1_mon[M - 1], d, h, m, s, f_len, f, y,\n                   (gmt) ? " GMT" : "") <= 0)\n        return (0);\n    else\n        return (1);\n err:\n    BIO_write(bp, "Bad time value", 14);\n    return (0);\n}']