Skip to content

robot.libdocpkg.output

get_generation_time

get_generation_time()

Return a timestamp that honors SOURCE_DATE_EPOCH.

This timestamp is to be used for embedding in output files, so that builds can be made reproducible.

Source code in src/robot/libdocpkg/output.py
def get_generation_time():
    """Return a timestamp that honors `SOURCE_DATE_EPOCH`.

    This timestamp is to be used for embedding in output files, so
    that builds can be made reproducible.
    """
    ts = float(os.getenv('SOURCE_DATE_EPOCH', time.time()))
    dt = datetime.datetime.fromtimestamp(round(ts), datetime.timezone.utc)
    return dt.isoformat()