99import posixpath
1010import re
1111import sys
12- import time
1312import types
1413import warnings
1514from os import path
4039from sphinx .search import js_index
4140from sphinx .theming import HTMLThemeFactory
4241from sphinx .util import isurl , logging
42+ from sphinx .util ._timestamps import _format_rfc3339_microseconds
4343from sphinx .util .display import progress_message , status_iterator
4444from sphinx .util .docutils import new_document
4545from sphinx .util .fileutil import copy_asset
4646from sphinx .util .i18n import format_date
4747from sphinx .util .inventory import InventoryFile
4848from sphinx .util .matching import DOTFILES , Matcher , patmatch
49- from sphinx .util .osutil import SEP , copyfile , ensuredir , os_path , relative_uri
49+ from sphinx .util .osutil import (
50+ SEP ,
51+ _last_modified_time ,
52+ copyfile ,
53+ ensuredir ,
54+ os_path ,
55+ relative_uri ,
56+ )
5057from sphinx .writers .html import HTMLWriter
5158from sphinx .writers .html5 import HTML5Translator
5259
@@ -397,7 +404,7 @@ def get_outdated_docs(self) -> Iterator[str]:
397404 pass
398405
399406 if self .templates :
400- template_mtime = self .templates .newest_template_mtime ()
407+ template_mtime = int ( self .templates .newest_template_mtime () * 10 ** 6 )
401408 else :
402409 template_mtime = 0
403410 for docname in self .env .found_docs :
@@ -407,19 +414,19 @@ def get_outdated_docs(self) -> Iterator[str]:
407414 continue
408415 targetname = self .get_outfilename (docname )
409416 try :
410- targetmtime = path . getmtime (targetname )
417+ targetmtime = _last_modified_time (targetname )
411418 except Exception :
412419 targetmtime = 0
413420 try :
414- srcmtime = max (path . getmtime (self .env .doc2path (docname )), template_mtime )
421+ srcmtime = max (_last_modified_time (self .env .doc2path (docname )), template_mtime )
415422 if srcmtime > targetmtime :
416423 logger .debug (
417424 '[build target] targetname %r(%s), template(%s), docname %r(%s)' ,
418425 targetname ,
419- _format_modified_time (targetmtime ),
420- _format_modified_time (template_mtime ),
426+ _format_rfc3339_microseconds (targetmtime ),
427+ _format_rfc3339_microseconds (template_mtime ),
421428 docname ,
422- _format_modified_time ( path . getmtime (self .env .doc2path (docname ))),
429+ _format_rfc3339_microseconds ( _last_modified_time (self .env .doc2path (docname ))),
423430 )
424431 yield docname
425432 except OSError :
@@ -1224,12 +1231,6 @@ def convert_html_css_files(app: Sphinx, config: Config) -> None:
12241231 config .html_css_files = html_css_files
12251232
12261233
1227- def _format_modified_time (timestamp : float ) -> str :
1228- """Return an RFC 3339 formatted string representing the given timestamp."""
1229- seconds , fraction = divmod (timestamp , 1 )
1230- return time .strftime ("%Y-%m-%d %H:%M:%S" , time .gmtime (seconds )) + f'.{ fraction :.3f} '
1231-
1232-
12331234def convert_html_js_files (app : Sphinx , config : Config ) -> None :
12341235 """Convert string styled html_js_files to tuple styled one."""
12351236 html_js_files : list [tuple [str , dict [str , str ]]] = []
0 commit comments