resolve_date_updated#

technote.metadata.builddate.resolve_date_updated(declared, source_dir, *, date_created=None)#

Resolve the date_updated for a technote build.

Parameters:
  • declared (datetime | None) – The date_updated declared in technote.toml, or None if it is not declared.

  • source_dir (Path) – The technote’s source directory, used to look up the git commit.

  • date_created (datetime | None, default: None) – The date_created declared in technote.toml, or None if it is not declared. A derived date_updated is never earlier than this date; a declared date_updated is left alone.

Returns:

The first available of, in order:

  1. The declared date_updated.

  2. The SOURCE_DATE_EPOCH environment variable.

  3. The committer date of the checked-out git commit.

  4. The current time, when the commit date cannot be read: the source directory is not inside a git repository, the repository has no commits yet, or reading the commit date failed. Only the last of those emits a Sphinx warning; see get_git_head_committer_date.

A derived date (2, 3 or 4) is clamped to date_created when it would otherwise be earlier: a bare date_created in technote.toml is anchored to midnight UTC, so a commit made earlier the same local day in a timezone ahead of UTC precedes it, and a technote must not report being modified before it was created.

Return type:

datetime.datetime