From 2e64c29e014391394898bbac05fc0c19bd1453b0 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 16 Nov 2015 23:51:21 +0100 Subject: [PATCH] use ISO-8601 date and time format, fixes #375 --- borg/archiver.py | 2 +- borg/helpers.py | 9 +++------ docs/conf.py | 4 ++-- docs/usage.rst | 8 ++++++++ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/borg/archiver.py b/borg/archiver.py index 9d65bec7b..f7090b0c4 100644 --- a/borg/archiver.py +++ b/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() diff --git a/borg/helpers.py b/borg/helpers.py index 1937c9bf0..e20aca6ed 100644 --- a/borg/helpers.py +++ b/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): diff --git a/docs/conf.py b/docs/conf.py index db9cd2de1..237f21adb 100644 --- a/docs/conf.py +++ b/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. diff --git a/docs/usage.rst b/docs/usage.rst index a585ee2fc..7a06ec8f5 100644 --- a/docs/usage.rst +++ b/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