diff --git a/api-ref/source/conf.py b/api-ref/source/conf.py index 5d7f7f3edc..de1197b48e 100644 --- a/api-ref/source/conf.py +++ b/api-ref/source/conf.py @@ -23,6 +23,7 @@ # All configuration values have a default; values that are commented out # serve to show the default. +import datetime import os from swift import __version__ import subprocess @@ -154,20 +155,22 @@ pygments_style = 'sphinx' # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. # html_last_updated_fmt = '%b %d, %Y' -git_cmd = ["git", "log", "--pretty=format:'%ad, commit %h'", "--date=local", - "-n1"] -try: - html_last_updated_fmt = subprocess.Popen( - git_cmd, stdout=subprocess.PIPE).communicate()[0] -except OSError: - warnings.warn('Cannot get last updated time from git repository. ' - 'Not setting "html_last_updated_fmt".') +if 'SOURCE_DATE_EPOCH' in os.environ: + now = float(os.environ.get('SOURCE_DATE_EPOCH')) + html_last_updated_fmt = datetime.datetime.utcfromtimestamp(now).isoformat() else: - if not isinstance(html_last_updated_fmt, str): - # for py3 - html_last_updated_fmt = html_last_updated_fmt.decode('ascii') - - + git_cmd = ["git", "log", "--pretty=format:'%ad, commit %h'", "--date=local", + "-n1"] + try: + html_last_updated_fmt = subprocess.Popen( + git_cmd, stdout=subprocess.PIPE).communicate()[0] + except OSError: + warnings.warn('Cannot get last updated time from git repository. ' + 'Not setting "html_last_updated_fmt".') + else: + if not isinstance(html_last_updated_fmt, str): + # for py3 + html_last_updated_fmt = html_last_updated_fmt.decode('ascii') # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. # html_use_smartypants = True diff --git a/doc/source/conf.py b/doc/source/conf.py index 09c7f11149..7b41b01e8e 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -72,7 +72,12 @@ master_doc = 'index' # General information about the project. project = u'Swift' -copyright = u'%d, OpenStack Foundation' % datetime.datetime.now().year +if 'SOURCE_DATE_EPOCH' in os.environ: + now = float(os.environ.get('SOURCE_DATE_EPOCH')) + now = datetime.datetime.utcfromtimestamp(now) +else: + now = datetime.date.today() +copyright = u'%d, OpenStack Foundation' % now.year # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the