borg icon indicating copy to clipboard operation
borg copied to clipboard

JSON: Use a more standard, timezone-aware format date time format

Open enkore opened this issue 8 years ago • 9 comments

Cf. #2368

Can be implemented similar to the output-type dependent file-size formatting.

enkore avatar Apr 01 '17 20:04 enkore

This is a fairly simple change, but I think it should really be made for 1.1.

enkore avatar Aug 02 '17 10:08 enkore

@enkore borg currently does a lot using localtime, but has no real timezone support (likely would require pytz). So I am not totally sure that even now all timestamps shown are totally correct (esp. regarding tzoffset and dst).

So how's your idea about this change being "fairly simple"?

ThomasWaldmann avatar Aug 05 '17 17:08 ThomasWaldmann

This issue would just be about using a ISO8601 format (and output in UTC), not true TZ support, which would probably be bigger.

This probably means to do a wrapper like that used for file-size formatting. It would convert to localtime + human format for __str__ and be converted to isoformat() for JSON.

enkore avatar Aug 05 '17 18:08 enkore

I am not sure this can be done cleanly without having aware datetime objects everywhere, so it might need a bit more work than just using a different format string (because if we say it is utc, we should be pretty sure it is).

ThomasWaldmann avatar Aug 05 '17 18:08 ThomasWaldmann

A first step could be to use the yyyy-mm-ddThh:mm:ss format without tz (so, no weekday and the T separator would be the difference to the human-readable iso-like format we use).

ThomasWaldmann avatar Aug 05 '17 23:08 ThomasWaldmann

partially addressed by #2925 (no tz yet), nothing to do left for 1.1 milestone.

ThomasWaldmann avatar Aug 22 '17 22:08 ThomasWaldmann

Would it maybe be an option for 1.2 to begin with storing an additional datetime with timezone for archive start and end times? And maybe also output them via (possibly unstable/transient x-start-tz) json keys, if a datetime with timezone is available as well?

sophie-h avatar May 12 '21 12:05 sophie-h

@ThomasWaldmann Maybe 2.0 is a good chance for doing everything properly with timezones?

sophie-h avatar Jul 17 '22 15:07 sophie-h

Yeah, would be good timing. But already a ton of other todo, do you want to work on it?

ThomasWaldmann avatar Jul 17 '22 15:07 ThomasWaldmann

I started working on it...

ThomasWaldmann avatar Aug 11 '22 20:08 ThomasWaldmann

Python (C?) wart: seems like strftime and strptime disagree on tz being with/without ":" between HH and MM.

ThomasWaldmann avatar Aug 11 '22 20:08 ThomasWaldmann