diff --git a/coverage/backward.py b/coverage/backward.py
index 37b491676..9d1d78e5b 100644
--- a/coverage/backward.py
+++ b/coverage/backward.py
@@ -9,6 +9,8 @@
import os
import sys
+from datetime import datetime
+
from coverage import env
@@ -217,6 +219,17 @@ def __eq__(self, other):
return self.__dict__ == other.__dict__
+def format_local_datetime(dt):
+ """Return a string with local timezone representing the date.
+ If python version is lower than 3.6, the time zone is not included.
+ """
+ try:
+ return dt.astimezone().strftime('%Y-%m-%d %H:%M %z')
+ except (TypeError, ValueError):
+ # Datetime.astimezone in Python 3.5 can not handle naive datetime
+ return dt.strftime('%Y-%m-%d %H:%M')
+
+
def invalidate_import_caches():
"""Invalidate any import caches that may or may not exist."""
if importlib and hasattr(importlib, "invalidate_caches"):
diff --git a/coverage/html.py b/coverage/html.py
index 596e11435..3596bbe1d 100644
--- a/coverage/html.py
+++ b/coverage/html.py
@@ -11,7 +11,7 @@
import coverage
from coverage import env
-from coverage.backward import iitems, SimpleNamespace
+from coverage.backward import iitems, SimpleNamespace, format_local_datetime
from coverage.data import add_data_to_hash
from coverage.files import flat_rootname
from coverage.misc import CoverageException, ensure_dir, file_be_gone, Hasher, isolate_module
@@ -200,7 +200,7 @@ def __init__(self, cov):
'__url__': coverage.__url__,
'__version__': coverage.__version__,
'title': title,
- 'time_stamp': datetime.datetime.now().strftime('%Y-%m-%d %H:%M'),
+ 'time_stamp': format_local_datetime(datetime.datetime.now()),
'extra_css': self.extra_css,
'has_arcs': self.has_arcs,
'show_contexts': self.config.show_contexts,
diff --git a/tests/gold/html/a/a_py.html b/tests/gold/html/a/a_py.html
index d534c6a34..af5d72a19 100644
--- a/tests/gold/html/a/a_py.html
+++ b/tests/gold/html/a/a_py.html
@@ -61,7 +61,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/a/index.html b/tests/gold/html/a/index.html
index e1c585fc9..3276f1d65 100644
--- a/tests/gold/html/a/index.html
+++ b/tests/gold/html/a/index.html
@@ -76,7 +76,7 @@ Coverage report:
coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/b_branch/b_py.html b/tests/gold/html/b_branch/b_py.html
index 67a1b83b3..ee28735e5 100644
--- a/tests/gold/html/b_branch/b_py.html
+++ b/tests/gold/html/b_branch/b_py.html
@@ -84,7 +84,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/b_branch/index.html b/tests/gold/html/b_branch/index.html
index 8b68b26e2..0dfc20cad 100644
--- a/tests/gold/html/b_branch/index.html
+++ b/tests/gold/html/b_branch/index.html
@@ -84,7 +84,7 @@ Coverage report:
coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/bom/2/bom_py.html b/tests/gold/html/bom/2/bom_py.html
index 74f4f2fee..a66988452 100644
--- a/tests/gold/html/bom/2/bom_py.html
+++ b/tests/gold/html/bom/2/bom_py.html
@@ -67,7 +67,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:32
+ created at 2019-10-14 09:32 +0000
diff --git a/tests/gold/html/bom/2/index.html b/tests/gold/html/bom/2/index.html
index 3fa67f0fa..28abec0a6 100644
--- a/tests/gold/html/bom/2/index.html
+++ b/tests/gold/html/bom/2/index.html
@@ -76,7 +76,7 @@ Coverage report:
coverage.py v5.0a9,
- created at 2019-10-13 11:41
+ created at 2019-10-13 11:41 +0000
diff --git a/tests/gold/html/bom/bom_py.html b/tests/gold/html/bom/bom_py.html
index 10b84edec..3b181c633 100644
--- a/tests/gold/html/bom/bom_py.html
+++ b/tests/gold/html/bom/bom_py.html
@@ -67,7 +67,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/bom/index.html b/tests/gold/html/bom/index.html
index b08e9c1c9..0e56a99a6 100644
--- a/tests/gold/html/bom/index.html
+++ b/tests/gold/html/bom/index.html
@@ -76,7 +76,7 @@ Coverage report:
coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/isolatin1/index.html b/tests/gold/html/isolatin1/index.html
index 7e33e754d..ec9c50b52 100644
--- a/tests/gold/html/isolatin1/index.html
+++ b/tests/gold/html/isolatin1/index.html
@@ -76,7 +76,7 @@ Coverage report:
coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/isolatin1/isolatin1_py.html b/tests/gold/html/isolatin1/isolatin1_py.html
index b344bad6b..3dd8c8fd0 100644
--- a/tests/gold/html/isolatin1/isolatin1_py.html
+++ b/tests/gold/html/isolatin1/isolatin1_py.html
@@ -61,7 +61,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/omit_1/index.html b/tests/gold/html/omit_1/index.html
index d8d02f6ab..a97add0f6 100644
--- a/tests/gold/html/omit_1/index.html
+++ b/tests/gold/html/omit_1/index.html
@@ -97,7 +97,7 @@ Coverage report:
coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/omit_1/m1_py.html b/tests/gold/html/omit_1/m1_py.html
index 57584495c..94fba21eb 100644
--- a/tests/gold/html/omit_1/m1_py.html
+++ b/tests/gold/html/omit_1/m1_py.html
@@ -58,7 +58,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/omit_1/m2_py.html b/tests/gold/html/omit_1/m2_py.html
index e8c1791d5..ade526d30 100644
--- a/tests/gold/html/omit_1/m2_py.html
+++ b/tests/gold/html/omit_1/m2_py.html
@@ -58,7 +58,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/omit_1/m3_py.html b/tests/gold/html/omit_1/m3_py.html
index e714d47f3..d6b4756d1 100644
--- a/tests/gold/html/omit_1/m3_py.html
+++ b/tests/gold/html/omit_1/m3_py.html
@@ -58,7 +58,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/omit_1/main_py.html b/tests/gold/html/omit_1/main_py.html
index 28173d12b..5d4781245 100644
--- a/tests/gold/html/omit_1/main_py.html
+++ b/tests/gold/html/omit_1/main_py.html
@@ -66,7 +66,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/omit_2/index.html b/tests/gold/html/omit_2/index.html
index d51ebd2a9..5b5e3c6ea 100644
--- a/tests/gold/html/omit_2/index.html
+++ b/tests/gold/html/omit_2/index.html
@@ -90,7 +90,7 @@ Coverage report:
coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/omit_2/m2_py.html b/tests/gold/html/omit_2/m2_py.html
index e8c1791d5..ade526d30 100644
--- a/tests/gold/html/omit_2/m2_py.html
+++ b/tests/gold/html/omit_2/m2_py.html
@@ -58,7 +58,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/omit_2/m3_py.html b/tests/gold/html/omit_2/m3_py.html
index e714d47f3..d6b4756d1 100644
--- a/tests/gold/html/omit_2/m3_py.html
+++ b/tests/gold/html/omit_2/m3_py.html
@@ -58,7 +58,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/omit_2/main_py.html b/tests/gold/html/omit_2/main_py.html
index 28173d12b..5d4781245 100644
--- a/tests/gold/html/omit_2/main_py.html
+++ b/tests/gold/html/omit_2/main_py.html
@@ -66,7 +66,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/omit_3/index.html b/tests/gold/html/omit_3/index.html
index 0d8ff217d..f5bc1aaeb 100644
--- a/tests/gold/html/omit_3/index.html
+++ b/tests/gold/html/omit_3/index.html
@@ -83,7 +83,7 @@ Coverage report:
coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/omit_3/m3_py.html b/tests/gold/html/omit_3/m3_py.html
index e714d47f3..d6b4756d1 100644
--- a/tests/gold/html/omit_3/m3_py.html
+++ b/tests/gold/html/omit_3/m3_py.html
@@ -58,7 +58,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/omit_3/main_py.html b/tests/gold/html/omit_3/main_py.html
index 28173d12b..5d4781245 100644
--- a/tests/gold/html/omit_3/main_py.html
+++ b/tests/gold/html/omit_3/main_py.html
@@ -66,7 +66,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/omit_4/index.html b/tests/gold/html/omit_4/index.html
index d91291fc4..861ba02e3 100644
--- a/tests/gold/html/omit_4/index.html
+++ b/tests/gold/html/omit_4/index.html
@@ -90,7 +90,7 @@ Coverage report:
coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/omit_4/m1_py.html b/tests/gold/html/omit_4/m1_py.html
index 57584495c..94fba21eb 100644
--- a/tests/gold/html/omit_4/m1_py.html
+++ b/tests/gold/html/omit_4/m1_py.html
@@ -58,7 +58,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/omit_4/m3_py.html b/tests/gold/html/omit_4/m3_py.html
index e714d47f3..d6b4756d1 100644
--- a/tests/gold/html/omit_4/m3_py.html
+++ b/tests/gold/html/omit_4/m3_py.html
@@ -58,7 +58,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/omit_4/main_py.html b/tests/gold/html/omit_4/main_py.html
index 28173d12b..5d4781245 100644
--- a/tests/gold/html/omit_4/main_py.html
+++ b/tests/gold/html/omit_4/main_py.html
@@ -66,7 +66,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/omit_5/index.html b/tests/gold/html/omit_5/index.html
index f1e0fe605..8afbebad5 100644
--- a/tests/gold/html/omit_5/index.html
+++ b/tests/gold/html/omit_5/index.html
@@ -83,7 +83,7 @@ Coverage report:
coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/omit_5/m1_py.html b/tests/gold/html/omit_5/m1_py.html
index 57584495c..94fba21eb 100644
--- a/tests/gold/html/omit_5/m1_py.html
+++ b/tests/gold/html/omit_5/m1_py.html
@@ -58,7 +58,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/omit_5/main_py.html b/tests/gold/html/omit_5/main_py.html
index 28173d12b..5d4781245 100644
--- a/tests/gold/html/omit_5/main_py.html
+++ b/tests/gold/html/omit_5/main_py.html
@@ -66,7 +66,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/other/blah_blah_other_py.html b/tests/gold/html/other/blah_blah_other_py.html
index 8f0309d49..d88e21e56 100644
--- a/tests/gold/html/other/blah_blah_other_py.html
+++ b/tests/gold/html/other/blah_blah_other_py.html
@@ -60,7 +60,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/other/here_py.html b/tests/gold/html/other/here_py.html
index c2f6b5f1f..94491fb0a 100644
--- a/tests/gold/html/other/here_py.html
+++ b/tests/gold/html/other/here_py.html
@@ -62,7 +62,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/other/index.html b/tests/gold/html/other/index.html
index fa1a770f4..644d14909 100644
--- a/tests/gold/html/other/index.html
+++ b/tests/gold/html/other/index.html
@@ -83,7 +83,7 @@ Coverage report:
coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/partial/index.html b/tests/gold/html/partial/index.html
index fa1ec4ad9..f766c0b4c 100644
--- a/tests/gold/html/partial/index.html
+++ b/tests/gold/html/partial/index.html
@@ -84,7 +84,7 @@ Coverage report:
coverage.py v5.0a9,
- created at 2019-10-14 12:01
+ created at 2019-10-14 12:01 +0000
diff --git a/tests/gold/html/partial/partial_py.html b/tests/gold/html/partial/partial_py.html
index abd755d00..c301a58a4 100644
--- a/tests/gold/html/partial/partial_py.html
+++ b/tests/gold/html/partial/partial_py.html
@@ -74,7 +74,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 12:01
+ created at 2019-10-14 12:01 +0000
diff --git a/tests/gold/html/styled/a_py.html b/tests/gold/html/styled/a_py.html
index 7b6f9dcdd..b81641cca 100644
--- a/tests/gold/html/styled/a_py.html
+++ b/tests/gold/html/styled/a_py.html
@@ -62,7 +62,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/styled/index.html b/tests/gold/html/styled/index.html
index 6e182fa63..d1a9259b6 100644
--- a/tests/gold/html/styled/index.html
+++ b/tests/gold/html/styled/index.html
@@ -77,7 +77,7 @@ Coverage report:
coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/unicode/index.html b/tests/gold/html/unicode/index.html
index bfa09a38d..b2de7b3d1 100644
--- a/tests/gold/html/unicode/index.html
+++ b/tests/gold/html/unicode/index.html
@@ -76,7 +76,7 @@ Coverage report:
coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/gold/html/unicode/unicode_py.html b/tests/gold/html/unicode/unicode_py.html
index a4218bcc9..311427d36 100644
--- a/tests/gold/html/unicode/unicode_py.html
+++ b/tests/gold/html/unicode/unicode_py.html
@@ -61,7 +61,7 @@
« index coverage.py v5.0a9,
- created at 2019-10-14 09:27
+ created at 2019-10-14 09:27 +0000
diff --git a/tests/test_html.py b/tests/test_html.py
index b543fa08e..6f22acc01 100644
--- a/tests/test_html.py
+++ b/tests/test_html.py
@@ -70,6 +70,11 @@ def get_html_index_content(self):
"""
with open("htmlcov/index.html") as f:
index = f.read()
+ index = re.sub(
+ r"created at \d{4}-\d{2}-\d{2} \d{2}:\d{2} \+\d{4}",
+ r"created at YYYY-MM-DD HH:MM +ZZZZ",
+ index,
+ )
index = re.sub(
r"created at \d{4}-\d{2}-\d{2} \d{2}:\d{2}",
r"created at YYYY-MM-DD HH:MM",
@@ -620,6 +625,7 @@ def compare_html(expected, actual):
scrubs = [
(r'/coverage.readthedocs.io/?[-.\w/]*', '/coverage.readthedocs.io/VER'),
(r'coverage.py v[\d.abc]+', 'coverage.py vVER'),
+ (r'created at \d\d\d\d-\d\d-\d\d \d\d:\d\d [-+]\d\d\d\d', 'created at DATE'),
(r'created at \d\d\d\d-\d\d-\d\d \d\d:\d\d', 'created at DATE'),
# Some words are identifiers in one version, keywords in another.
(r'(print|True|False)', r'\2'),