in reply to How To Modify PDF Metadata [SOLVED]

The months returned from localtime are in the range 0-11, so where you add 1900 to the year you should also add 1 to the month.

Replies are listed 'Best First'.
Re^2: How To Modify PDF Metadata
by karlgoethebier (Abbot) on Jun 13, 2015 at 16:37 UTC

    Thank you very much hippo for advice.

    For my rehabilitation i would like to say that i was a bit confused about this issue. I observed different behavior of my code on Win, Linux and Mac. And the various timestamp formats that one can pass to PDFs are a mess and put me over the edge. Perhaps i didn't see the basic problem and jumped to some wrong conclusions ;-).

    For completeness:

    "$mday is the day of the month and $mon the month in the range 0..11..."
    karls-mac-mini:monks karl$ perl -E '$day=(localtime)[3]; say $day;' 13 karls-mac-mini:monks karl$ perl -E '$month=(localtime)[4]; say $month; +' 5 karls-mac-mini:monks karl$ perl -E '$month=(localtime)[4]; say ++$mont +h;' 6 karls-mac-mini:monks karl$ date +%m 06

    D'oh!

    Update: I just run my modified code on a PDF created on Win:

    CreationDate was 06.06.2015 16:12 and now it is 06.06.2015 18:12.

    This crap drives me insane.

    Edit: Minor changes. Ain't no fun no more.

    Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

      Hmm, not sure to understand exactly your problem, but this two-hours difference may be the difference between localtime (time in the local time zone) and gmtime (UTC time), which is two hours in the time zone where both you and I live.

      Or did I miss the point?

        "...Or did I miss the point?"

        I guess not Laurent_R. Or i don't know it better for the moment. But please see my second update in my OP.

        Best regards, Karl

        «The Crux of the Biscuit is the Apostrophe»

Re^2: How To Modify PDF Metadata
by karlgoethebier (Abbot) on Jun 13, 2015 at 14:57 UTC
    "...add 1 to the month."

    Update:

    Well, i say $m_month += 1; but i still get 2015:01:07 14:46:51

    karls-mac-mini:monks karl$ perl -MImage::ExifTool=:Public -E 'say Imag +eInfo("./pdf/a.pdf")->{CreateDate};' 2015:02:07 14:46:51 karls-mac-mini:monks karl$ ls ./pdf/a.pdf -rw-r--r--@ 1 karl karl 48K 7 Feb 14:46 ./pdf/a.pdf

    Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

Re^2: How To Modify PDF Metadata
by Anonymous Monk on Jun 14, 2015 at 06:16 UTC
      "...what you want to use for date math..."

      Yes and no.

      Despite my annoying mistake: I used Date::Calc until someone told me it's API is inferior and that the new kid on the block is much cooler.

      So i crucify myself with the manpage.

      And why should i use .45 if .22 does the job less expensive:

      karls-mac-mini:monks karl$ perl -MPOSIX=strftime -E 'say strftime("%Y +:%m:%d %H:%M:%S%z", localtime() );' 2015:06:14 19:42:10+0200

      Best regards, Karl

      «The Crux of the Biscuit is the Apostrophe»