mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-21 13:47:16 +00:00
archives list: use iso8601 timestamp format with --json
like yyyy-mm-ddThh:mm:ss - no tz yet, this likely needs more refactoring
to tz aware and utc datetime objects everywhere, currently there are
naive datetime objects and also localtime at quite some places.
(cherry picked from commit b64561fe6f
)
This commit is contained in:
parent
d17553add6
commit
65940be21a
1 changed files with 12 additions and 3 deletions
|
@ -1660,6 +1660,7 @@ def __init__(self, format, repository, manifest, key, *, json=False):
|
|||
if self.json:
|
||||
self.item_data = {}
|
||||
self.format_item = self.format_item_json
|
||||
self.format_time = self.format_time_json
|
||||
else:
|
||||
self.item_data = static_keys
|
||||
|
||||
|
@ -1676,8 +1677,8 @@ def get_item_data(self, archive_info):
|
|||
'archive': remove_surrogates(archive_info.name),
|
||||
'barchive': archive_info.name,
|
||||
'id': bin_to_hex(archive_info.id),
|
||||
'time': format_time(to_localtime(archive_info.ts)),
|
||||
'start': format_time(to_localtime(archive_info.ts)),
|
||||
'time': self.format_time(archive_info.ts),
|
||||
'start': self.format_time(archive_info.ts),
|
||||
})
|
||||
for key in self.used_call_keys:
|
||||
item_data[key] = self.call_keys[key]()
|
||||
|
@ -1695,7 +1696,15 @@ def get_comment(self, rs):
|
|||
return remove_surrogates(self.archive.comment) if rs else self.archive.comment
|
||||
|
||||
def get_ts_end(self):
|
||||
return format_time(to_localtime(self.archive.ts_end))
|
||||
return self.format_time(self.archive.ts_end)
|
||||
|
||||
def format_time(self, ts):
|
||||
t = to_localtime(ts)
|
||||
return format_time(t)
|
||||
|
||||
def format_time_json(self, ts):
|
||||
t = to_localtime(ts)
|
||||
return isoformat_time(t)
|
||||
|
||||
|
||||
class ItemFormatter(BaseFormatter):
|
||||
|
|
Loading…
Reference in a new issue