From af1bb582742ee329013278c8e05f6753ef43e49f Mon Sep 17 00:00:00 2001 From: Simon Gerber Date: Wed, 14 Apr 2010 15:00:57 +0200 Subject: [PATCH] Added support for displaying dates in localtime. [ jf: updated documentation and added NEWS entry ] Signed-off-by: Jonas Fonseca --- NEWS | 1 + manual.txt | 2 +- tig.c | 9 ++++++++- tigrc.5.txt | 4 ++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 815f246..b3eeb49 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,7 @@ Improvements: flag). - Abbreviation of author names can now be configured and toggled. - Mark detached heads with [HEAD]. + - Add support for displaying dates in local time. Bug fixes: diff --git a/manual.txt b/manual.txt index cfc26c6..41d9bf9 100644 --- a/manual.txt +++ b/manual.txt @@ -434,7 +434,7 @@ Misc |v |Show version. |o |Open option menu |. |Toggle line numbers on/off. -|D |Toggle date display on/off/relative. +|D |Toggle date display on/off/short/relative/local. |A |Toggle author display on/off/abbreviated. |g |Toggle revision graph visualization on/off. |F |Toggle reference display on/off (tag and branch names). diff --git a/tig.c b/tig.c index 05379fb..7cdd3ea 100644 --- a/tig.c +++ b/tig.c @@ -519,6 +519,7 @@ utf8_length(const char **start, size_t skip, int *width, size_t max_width, int * #define DATE_INFO \ DATE_(NO), \ DATE_(DEFAULT), \ + DATE_(LOCAL), \ DATE_(RELATIVE), \ DATE_(SHORT) @@ -583,7 +584,13 @@ mkdate(const struct time *time, enum date date) } } - gmtime_r(&time->sec, &tm); + if (date == DATE_LOCAL) { + time_t date = time->sec + time->tz; + localtime_r(&date, &tm); + } + else { + gmtime_r(&time->sec, &tm); + } return strftime(buf, sizeof(buf), DATE_FORMAT, &tm) ? buf : NULL; } diff --git a/tigrc.5.txt b/tigrc.5.txt index ef93d27..c54adec 100644 --- a/tigrc.5.txt +++ b/tigrc.5.txt @@ -97,11 +97,11 @@ The following variables can be set: How to display author names. If set to "abbreviated" author initials will be shown. Can be toggled. -'show-date' (mixed) ["relative" | "short" | "default" | bool]:: +'show-date' (mixed) ["relative" | "short" | "default" | "local" | bool]:: Whether and how to show date. If set to "relative" a relative date will be used, e.g. "2 minutes ago". If set to "short" no time information is - shown. Can be toggled. + shown. If set to "local", localtime(3) is used. Can be toggled. 'author-width' (int):: -- 2.30.2