Pārlūkot izejas kodu

use ISO-8601 date and time format, fixes #375

Thomas Waldmann 9 gadi atpakaļ
vecāks
revīzija
2e64c29e01
4 mainītis faili ar 14 papildinājumiem un 9 dzēšanām
  1. 1 1
      borg/archiver.py
  2. 3 6
      borg/helpers.py
  3. 2 2
      docs/conf.py
  4. 8 0
      docs/usage.rst

+ 1 - 1
borg/archiver.py

@@ -431,7 +431,7 @@ class Archiver:
         print('Fingerprint: %s' % hexlify(archive.id).decode('ascii'))
         print('Hostname:', archive.metadata[b'hostname'])
         print('Username:', archive.metadata[b'username'])
-        print('Time: %s' % to_localtime(archive.ts).strftime('%c'))
+        print('Time: %s' % format_time(to_localtime(archive.ts)))
         print('Command line:', remove_surrogates(' '.join(archive.metadata[b'cmdline'])))
         print('Number of files: %d' % stats.nfiles)
         print()

+ 3 - 6
borg/helpers.py

@@ -449,12 +449,9 @@ def dir_is_tagged(path, exclude_caches, exclude_if_present):
 
 
 def format_time(t):
-    """Format datetime suitable for fixed length list output
+    """use ISO-8601 date and time format
     """
-    if abs((datetime.now() - t).days) < 365:
-        return t.strftime('%b %d %H:%M')
-    else:
-        return t.strftime('%b %d  %Y')
+    return t.strftime('%Y-%m-%d %H:%M:%S')
 
 
 def format_timedelta(td):
@@ -510,7 +507,7 @@ def sizeof_fmt_decimal(num, suffix='B', sep='', precision=2):
 
 
 def format_archive(archive):
-    return '%-36s %s' % (archive.name, to_localtime(archive.ts).strftime('%c'))
+    return '%-36s %s' % (archive.name, format_time(to_localtime(archive.ts)))
 
 
 def memoize(function):

+ 2 - 2
docs/conf.py

@@ -63,7 +63,7 @@ release = version
 # non-false value, then it is used:
 #today = ''
 # Else, today_fmt is used as the format for a strftime call.
-#today_fmt = '%B %d, %Y'
+today_fmt = '%Y-%m-%d'
 
 # List of patterns, relative to source directory, that match files and
 # directories to ignore when looking for source files.
@@ -131,7 +131,7 @@ html_favicon = '_static/favicon.ico'
 
 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
 # using the given strftime format.
-#html_last_updated_fmt = '%b %d, %Y'
+html_last_updated_fmt = '%Y-%m-%d'
 
 # If true, SmartyPants will be used to convert quotes and dashes to
 # typographically correct entities.

+ 8 - 0
docs/usage.rst

@@ -140,6 +140,14 @@ indicated using the `IEC binary prefixes
 using powers of two (so ``KiB`` means 1024 bytes).
 
 
+Date and Time
+~~~~~~~~~~~~~
+
+We format date and time conforming to ISO-8601, that is: YYYY-MM-DD and HH:MM:SS
+
+For more information, see: https://xkcd.com/1179/
+
+
 .. include:: usage/init.rst.inc
 
 Examples