Skip to content

Commit

Permalink
Store time in microseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Jul 20, 2023
1 parent 9174c15 commit c18d8d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sphinx/builders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def read_doc(self, docname: str, *, _cache: bool = True) -> None:
doctree = publisher.document

# store time of reading, for outdated files detection
self.env.all_docs[docname] = time.time_ns()
self.env.all_docs[docname] = time.time_ns() // 1_000

# cleanup
self.env.temp_data.clear()
Expand Down
6 changes: 3 additions & 3 deletions sphinx/environment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def __init__(self, app: Sphinx):
# All "docnames" here are /-separated and relative and exclude
# the source suffix.

# docname -> time of reading (in integer nanoseconds)
# docname -> time of reading (in integer microseconds)
# contains all read docnames
self.all_docs: dict[str, int] = {}
# docname -> set of dependent file
Expand Down Expand Up @@ -480,7 +480,7 @@ def get_outdated_files(self, config_changed: bool) -> tuple[set[str], set[str],
changed.add(docname)
continue
# check the mtime of the document
mtime = self.all_docs[docname] // 1_000 # convert ns to μs
mtime = self.all_docs[docname]
newmtime = _last_modified_time(self.doc2path(docname))
if newmtime > mtime:
# convert integer microseconds to floating-point seconds,
Expand Down Expand Up @@ -735,7 +735,7 @@ def check_consistency(self) -> None:
def _last_modified_time(filename: str) -> int:
"""Return the last modified time of ``filename``.
The time is returned as integer milliseconds.
The time is returned as integer microseconds.
The lowest common denominator of modern file-systems seems to be
microsecond-level precision.
Expand Down

0 comments on commit c18d8d2

Please sign in to comment.