Skip to main content

pdf_date

Function pdf_date 

Source
pub fn pdf_date(time: SystemTime) -> String
Expand description

time as a PDF date string (ISO 32000-1 §7.9.4): D:YYYYMMDDHHmmSSZ00'00', always in UTC, which is the one zone every reader agrees on.

A time before 1970 reads as the epoch.

use std::time::{Duration, UNIX_EPOCH};
use pdfrum_edit::pdf_date;

assert_eq!(pdf_date(UNIX_EPOCH), "D:19700101000000Z00'00'");
assert_eq!(
    pdf_date(UNIX_EPOCH + Duration::from_secs(1_700_000_000)),
    "D:20231114221320Z00'00'"
);