Promote verified native PDF and box capacity support
This commit is contained in:
1 parent
3706afa483
commit
72ed779749
31 files changed
+1042
-78
No files matched your search
@@ -14,8 +14,8 @@ pub enum JobParameter {
|
||||
Year,
|
||||
}
|
||||
|
||||
/// One real host-local timestamp, captured at job start. Tests may inject an
|
||||
/// explicit timestamp; absence is an error on access, never a fake zero date.
|
||||
/// The TeX time registers and PDF creation timestamp captured at job start.
|
||||
/// The host can supply a separate PDF date for reproducible builds.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||
pub struct JobTime {
|
||||
pub year: i32,
|
||||
@@ -24,6 +24,8 @@ pub struct JobTime {
|
||||
pub minutes: i32,
|
||||
#[serde(default)]
|
||||
pdf_clock: Option<(u8, i16)>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pdf_calendar: Option<(i32, i32, i32, i32)>,
|
||||
}
|
||||
impl JobTime {
|
||||
pub fn new(year: i32, month: i32, day: i32, minutes: i32) -> Result<Self, &'static str> {
|
||||
@@ -44,6 +46,7 @@ impl JobTime {
|
||||
day,
|
||||
minutes,
|
||||
pdf_clock: None,
|
||||
pdf_calendar: None,
|
||||
})
|
||||
}
|
||||
/// Add the seconds and UTC offset supplied by the job host.
|
||||
@@ -56,11 +59,28 @@ impl JobTime {
|
||||
return Err("invalid host PDF creation timestamp");
|
||||
}
|
||||
self.pdf_clock = Some((seconds, offset_minutes));
|
||||
self.pdf_calendar = None;
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
/// Use the PDF timestamp from another host clock without changing TeX's registers.
|
||||
pub fn with_pdf_date(mut self, source: Self) -> Self {
|
||||
let calendar =
|
||||
source
|
||||
.pdf_calendar
|
||||
.unwrap_or((source.year, source.month, source.day, source.minutes));
|
||||
self.pdf_clock = source.pdf_clock;
|
||||
self.pdf_calendar = (source.pdf_clock.is_some()
|
||||
&& calendar != (self.year, self.month, self.day, self.minutes))
|
||||
.then_some(calendar);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn pdf_creation_date(self) -> Option<String> {
|
||||
let (seconds, offset) = self.pdf_clock?;
|
||||
let (year, month, day, minutes) =
|
||||
self.pdf_calendar
|
||||
.unwrap_or((self.year, self.month, self.day, self.minutes));
|
||||
let zone = if offset == 0 {
|
||||
"Z".to_owned()
|
||||
} else {
|
||||
@@ -69,12 +89,9 @@ impl JobTime {
|
||||
format!("{sign}{:02}'{:02}'", offset / 60, offset % 60)
|
||||
};
|
||||
Some(format!(
|
||||
"D:{:04}{:02}{:02}{:02}{:02}{seconds:02}{zone}",
|
||||
self.year,
|
||||
self.month,
|
||||
self.day,
|
||||
self.minutes / 60,
|
||||
self.minutes % 60
|
||||
"D:{year:04}{month:02}{day:02}{:02}{:02}{seconds:02}{zone}",
|
||||
minutes / 60,
|
||||
minutes % 60
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user