Explorar el Código

Merge pull request #4067 from audeoudh/1.1-maint

Forward the `format_spec` to `datetime` class (1.1 backport)
TW hace 6 años
padre
commit
ac7bfec4a3
Se han modificado 1 ficheros con 3 adiciones y 3 borrados
  1. 3 3
      src/borg/helpers.py

+ 3 - 3
src/borg/helpers.py

@@ -747,11 +747,11 @@ def safe_timestamp(item_timestamp_ns):
     return datetime.fromtimestamp(t_ns / 1e9)
     return datetime.fromtimestamp(t_ns / 1e9)
 
 
 
 
-def format_time(ts: datetime):
+def format_time(ts: datetime, format_spec=''):
     """
     """
     Convert *ts* to a human-friendly format with textual weekday.
     Convert *ts* to a human-friendly format with textual weekday.
     """
     """
-    return ts.strftime('%a, %Y-%m-%d %H:%M:%S')
+    return ts.strftime('%a, %Y-%m-%d %H:%M:%S' if format_spec == '' else format_spec)
 
 
 
 
 def isoformat_time(ts: datetime):
 def isoformat_time(ts: datetime):
@@ -786,7 +786,7 @@ class OutputTimestamp:
         self.ts = ts
         self.ts = ts
 
 
     def __format__(self, format_spec):
     def __format__(self, format_spec):
-        return format_time(self.ts)
+        return format_time(self.ts, format_spec=format_spec)
 
 
     def __str__(self):
     def __str__(self):
         return '{}'.format(self)
         return '{}'.format(self)