Skip to main content

commit_timestamp

Function commit_timestamp 

Source
pub fn commit_timestamp(explicit: Option<u64>) -> Result<u64, TimestampError>
Expand description

Returns the timestamp of a new commit.

The timestamp is in seconds since the Unix epoch, UTC. The function takes it from the first of these sources that is set:

  1. explicit
  2. the SOURCE_DATE_EPOCH environment variable
  3. the system clock

The function trims white space from SOURCE_DATE_EPOCH before it parses the value. If SOURCE_DATE_EPOCH is not valid Unicode, the function treats it as unset.

ยงErrors

  • TimestampError::SourceDateEpoch if explicit is None and SOURCE_DATE_EPOCH is set to a value that is not a count of seconds. The function does not use the clock in this case, as the reproducible-build convention requires.
  • TimestampError::ClockBeforeEpoch if the function reads the system clock and the clock is before the Unix epoch.