Code

Added support for displaying dates in localtime.
authorSimon Gerber <simugerber@student.ethz.ch>
Wed, 14 Apr 2010 13:00:57 +0000 (15:00 +0200)
committerJonas Fonseca <fonseca@diku.dk>
Mon, 19 Apr 2010 00:53:30 +0000 (20:53 -0400)
[ jf: updated documentation and added NEWS entry ]

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
NEWS
manual.txt
tig.c
tigrc.5.txt

diff --git a/NEWS b/NEWS
index 815f246ee897cdab99db03a0c43fb18f2aeed043..b3eeb497a9ab2262817b2927edd8398e94fb3ae4 100644 (file)
--- 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].
    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:
 
 
 Bug fixes:
 
index cfc26c67840b68d5054767f2b12a11375a228cb3..41d9bf9797e0f7d12e69decf638cef30ed0a4d2d 100644 (file)
@@ -434,7 +434,7 @@ Misc
 |v     |Show version.
 |o     |Open option menu
 |.     |Toggle line numbers on/off.
 |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).
 |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 05379fbc4d59bba134ad9c893b167423d02be460..7cdd3eaa3371202ed2016eec4cb2e9ec03545295 100644 (file)
--- 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), \
 #define DATE_INFO \
        DATE_(NO), \
        DATE_(DEFAULT), \
+       DATE_(LOCAL), \
        DATE_(RELATIVE), \
        DATE_(SHORT)
 
        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;
 }
 
        return strftime(buf, sizeof(buf), DATE_FORMAT, &tm) ? buf : NULL;
 }
 
index ef93d27bef930806a8bba18088e3d4942a66eaec..c54adec5c395868be40b956d3e28e74f44f81b01 100644 (file)
@@ -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.
 
        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
 
        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)::
 
 
 'author-width' (int)::