diff options
author | patrick <p.totzke@ed.ac.uk> | 2011-08-18 14:07:19 +0100 |
---|---|---|
committer | patrick <p.totzke@ed.ac.uk> | 2011-08-18 14:07:19 +0100 |
commit | 885682645902fab6a260043058ac162b22c38c5a (patch) | |
tree | 21ad7c236a11984c02081180257e21a653b46730 /alot | |
parent | ad0897d6a40b29d5afb36b35307815428267f30b (diff) |
make formatstring for timestamps configurable.
This adds a new config option 'timestamp_format'
to the globals section that, if set, is used to format
datetimes in thread and search buffers. Caution:
It accepts standart strftime strings, see:
http://docs.python.org/library/datetime.html#strftime-strptime-behavior
BUT: as configparser uses '%' internally, you must escape
them by using '%%'.
Diffstat (limited to 'alot')
-rw-r--r-- | alot/message.py | 13 | ||||
-rw-r--r-- | alot/settings.py | 1 | ||||
-rw-r--r-- | alot/widgets.py | 7 |
3 files changed, 16 insertions, 5 deletions
diff --git a/alot/message.py b/alot/message.py index d464fdfd..29f8896f 100644 --- a/alot/message.py +++ b/alot/message.py @@ -26,6 +26,7 @@ from email.header import Header import helper from settings import get_mime_handler +from settings import config class Message: @@ -55,7 +56,6 @@ class Message: aname, aaddress = self.get_author() if not aname: aname = aaddress - #tags = ','.join(self.get_tags()) return "%s (%s)" % (aname, self.get_datestring()) def __hash__(self): @@ -116,9 +116,14 @@ class Message: t = self.get_thread() return t.get_replies_to(self) - def get_datestring(self, pretty=True): - """returns formated datestring in sup-style, eg: 'Yest.3pm'""" - return helper.pretty_datetime(self._datetime) + def get_datestring(self): + """returns formated datestring""" + formatstring = config.get('general', 'timestamp_format') + if formatstring: + res = self._datetime.strftime(formatstring) + else: + res = helper.pretty_datetime(self._datetime) + return res def get_author(self): """returns realname and address pair of this messages author""" diff --git a/alot/settings.py b/alot/settings.py index dd399fcd..6bba50ad 100644 --- a/alot/settings.py +++ b/alot/settings.py @@ -39,6 +39,7 @@ DEFAULTS = { 'flush_retry_timeout': '5', 'hooksfile': '~/.alot.py', 'bug_on_exit': 'False', + 'timestamp_format': '', }, '16c-theme': { 'bufferlist_focus_bg': 'dark gray', diff --git a/alot/widgets.py b/alot/widgets.py index 34faa179..690c6260 100644 --- a/alot/widgets.py +++ b/alot/widgets.py @@ -40,7 +40,12 @@ class ThreadlineWidget(urwid.AttrMap): def rebuild(self): cols = [] - datestring = pretty_datetime(self.thread.get_newest_date()).rjust(10) + formatstring = config.get('general', 'timestamp_format') + newest = self.thread.get_newest_date() + if formatstring: + datestring = newest.strftime(formatstring) + else: + datestring = pretty_datetime(newest).rjust(10) self.date_w = urwid.AttrMap(urwid.Text(datestring), 'threadline_date') cols.append(('fixed', len(datestring), self.date_w)) |