Skip to main content

ReferenceTime

Struct ReferenceTime 

Source
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

Source

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.

Source

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

Source§

fn clone(&self) -> ReferenceTime

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ReferenceTime

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ReferenceTime

Source§

impl Hash for ReferenceTime

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ReferenceTime

Source§

fn eq(&self, other: &ReferenceTime) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ReferenceTime

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.