1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-27 10:18:12 +00:00

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...
This commit is contained in:
Milkey Mouse 2018-03-27 12:55:32 -07:00
parent 1c74d0d7fe
commit ecc1a9c499
No known key found for this signature in database
GPG key ID: C6EF5A02F5647987

View file

@ -665,14 +665,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,