diff options
author | Lars Wirzenius <liw@liw.fi> | 2015-12-17 21:50:40 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2015-12-17 21:50:40 +0100 |
commit | 2e6b7b0b7e812834025afb74f479e91c6382bc96 (patch) | |
tree | acbdeb467346a8746c29e8795d76bf891aa0f647 | |
parent | 31cd9ba9f967125ea7954c0d066146c55ded5394 (diff) | |
download | obnam-2e6b7b0b7e812834025afb74f479e91c6382bc96.tar.gz |
Show time zone in "obnam generations"
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | obnamlib/plugins/show_plugin.py | 17 |
2 files changed, 20 insertions, 1 deletions
@@ -26,6 +26,10 @@ Improvements to the manual: * The manual now has sections on turning on full debug logging and reporting problems. +Improvements to functionality: + +* The output of `obnam generations` now show time zone. Lars Wirzenius + implemented based on suggestion by Limdi. Version 1.18.2, released 2015-11-15 --------------------------------- diff --git a/obnamlib/plugins/show_plugin.py b/obnamlib/plugins/show_plugin.py index a14852de..c2f8aa02 100644 --- a/obnamlib/plugins/show_plugin.py +++ b/obnamlib/plugins/show_plugin.py @@ -209,7 +209,22 @@ class ShowPlugin(obnamlib.ObnamPlugin): return filename def format_time(self, timestamp): - return time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(timestamp)) + prefix = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(timestamp)) + return prefix + ' ' + self.format_timezone() + + def format_timezone(self): + '''Return a timezone indication on +0300 format.''' + + # A zero offset gets a plus sign. The time.timezone value has the + # opposite sign of what we want in the output. + if time.timezone <= 0: + sign = '+' + else: + sign = '-' + + hh = abs(time.timezone) / 3600 + mm = (abs(time.timezone) % 3600) / 60 + return '%c%02d%02d' % (sign, hh, mm) def isdir(self, gen_id, filename): mode = self.repo.get_file_key( |