From 64793d5c15085dca5098abaa48ba638211a26314 Mon Sep 17 00:00:00 2001 From: Milkey Mouse Date: Tue, 27 Mar 2018 12:55:32 -0700 Subject: [PATCH] Use same datetime object for {now} and {utcnow} (fixes #3548) {now} and {utcnow} should point to the same exact momemt, but they don't because .now() and .utcnow() create two different objects at different times. Although the difference will be on the order of microseconds on all but the slowest machines, this bug still tickles my inner pedant... --- src/borg/helpers/parseformat.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/borg/helpers/parseformat.py b/src/borg/helpers/parseformat.py index 4c5b42f15..cb3796e83 100644 --- a/src/borg/helpers/parseformat.py +++ b/src/borg/helpers/parseformat.py @@ -180,14 +180,14 @@ def format_line(format, data): def replace_placeholders(text): """Replace placeholders in text with their values.""" from ..platform import fqdn - current_time = datetime.now() + current_time = datetime.now(timezone.utc) data = { 'pid': os.getpid(), 'fqdn': fqdn, 'reverse-fqdn': '.'.join(reversed(fqdn.split('.'))), 'hostname': socket.gethostname(), - 'now': DatetimeWrapper(current_time.now()), - 'utcnow': DatetimeWrapper(current_time.utcnow()), + 'now': DatetimeWrapper(current_time.astimezone(None)), + 'utcnow': DatetimeWrapper(current_time), 'user': uid2user(os.getuid(), os.getuid()), 'uuid4': str(uuid.uuid4()), 'borgversion': borg_version,