eric6/DebugClients/Python/coverage/backward.py

changeset 7702
f8b97639deb5
parent 7427
362cd1b6f81a
--- a/eric6/DebugClients/Python/coverage/backward.py	Tue Sep 15 19:09:05 2020 +0200
+++ b/eric6/DebugClients/Python/coverage/backward.py	Thu Sep 17 19:10:36 2020 +0200
@@ -9,6 +9,8 @@
 import os
 import sys
 
+from datetime import datetime
+
 from coverage import env
 
 
@@ -217,6 +219,17 @@
             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"):

eric ide

mercurial