[NTG-pdftex] Patch CreationDate

Martin Schroeder ms@artcom-gmbh.de
Thu, 31 Jul 2003 18:59:04 +0200


On 2003-07-31 17:04:06 +0200, Martin Schröder wrote:
> I also tried leaving out the tz information in /CreationDate by
> setting O to Z and leaving out the offset; but AR5 ignores any
> offset and interprets the time as CEST. :-(

Thanks to Thomas I think I have a solution (idea borrowed from sendmail):

void printcreationdate()
{
    time_t t;
    struct tm lt, gmt;
    size_t size;
    char time_str[20];
    int off, hours, minutes;

    /* get the time */
    t = time(NULL);
    lt = *localtime(&t);
    size = strftime(time_str, sizeof(time_str), "%Y%m%d%H%M%S", &lt);
    /* expected format: "YYYYmmddHHMMSS" */

    /* correction for seconds: %S can be in range 00..61,
       the PDF reference expects 00..59,
       therefore we map "60" and "61" to "59" */
    if (time_str[12] == '6') {
        time_str[12] == '5';
        time_str[13] == '9';
    }

    /* get the time zone offset */
    gmt = *gmtime(&t);
    off = (lt.tm_hour - gmt.tm_hour) * 60 + lt.tm_min - gmt.tm_min;
#ifdef DEBUG
    fprintf(stderr, "\noff: %i\n", off);
#endif
    hours = off/60;
    minutes = (abs(off) - (abs(hours) * 60))/60;
    sprintf (&time_str[size], "%+03i'%02d'", hours, minutes);

    /* print result */
    pdf_printf("/CreationDate (D:%s)\n", time_str);
}

off is 120. :-)

Best regards
        Martin
-- 
               Martin Schröder, MS@ArtCom-GmbH.DE
     ArtCom GmbH, Lise-Meitner-Str 5, 28359 Bremen, Germany
          Voice +49 421 20419-44 / Fax +49 421 20419-10