pub struct ReferenceTime { /* private fields */ }Expand description
A fixed reference instant used to compute the time-dependent document
attributes (docdate, doctime, docdatetime, docyear, and their
local* siblings).
AsciiDoc derives these attributes from a reference time: normally the
modification time of the source file (for doc*) and the current wall-clock
time (for local*). Because those values change from run to run, output
that embeds them is not reproducible. Supplying a ReferenceTime pins the
clock to a known instant so that the computed attributes — and any output
derived from them — are stable and reproducible.
A ReferenceTime records a local wall-clock date and time together with
the UTC offset in effect at that instant. The offset governs how the
computed doctime / localtime prints its zone: UTC when the offset is
zero, otherwise a numeric ±HHMM suffix (matching Asciidoctor’s use of
%Z/%z).
Install one with Parser::with_reference_time (pins the whole clock) or
Parser::with_input_mtime (pins only the source-file time that drives the
doc* attributes). See also the SOURCE_DATE_EPOCH environment variable,
which pins the clock when no ReferenceTime is supplied.
Implementations§
Source§impl ReferenceTime
impl ReferenceTime
Sourcepub fn from_unix_timestamp(secs: i64) -> Self
pub fn from_unix_timestamp(secs: i64) -> Self
Creates a reference time from a count of seconds since the Unix epoch (1970-01-01T00:00:00Z), interpreted as UTC.
This is the shape of the SOURCE_DATE_EPOCH value defined by the
reproducible builds specification. The resulting doctime /
localtime prints its zone as UTC.
Sourcepub fn from_local(
year: i64,
month: u32,
day: u32,
hour: u32,
minute: u32,
second: u32,
utc_offset_secs: i32,
) -> Self
pub fn from_local( year: i64, month: u32, day: u32, hour: u32, minute: u32, second: u32, utc_offset_secs: i32, ) -> Self
Creates a reference time from an explicit local wall-clock date and time and the UTC offset (in seconds) in effect at that instant.
This mirrors constructing a timezone-aware time such as Asciidoctor’s
input_mtime. The offset controls the printed zone of the computed
doctime / localtime: UTC when utc_offset_secs is 0, otherwise
a numeric ±HHMM suffix (e.g. a +06:00 offset prints as +0600).
The components are stored as given and are not validated or normalized; supplying out-of-range values yields correspondingly out-of-range output.
Trait Implementations§
Source§impl Clone for ReferenceTime
impl Clone for ReferenceTime
Source§fn clone(&self) -> ReferenceTime
fn clone(&self) -> ReferenceTime
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more