The default ISO 8601 modifier %ci is quite verbose displaying
everything up to the timezone. This consumes considerable amount of
characters. The new modifiers offer way to display just the needed
amount of information, down to:%cID date: YYYY-MM-DD
%cIH hour: YYYY-MM-DD HH:MM
%cIS second: YYYY-MM-DD HH:MM:SSSigned-off-by: Jari Aalto <jari.aalto AT cante.net>
---
Documentation/pretty-formats.txt | 5 ++++-
cache.h | 3 +++
date.c | 17 +++++++++++++++++
pretty.c | 35 ++++++++++++++++++++++++++++++-----
4 files changed, 54 insertions(+), 6 deletions(-)diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index 0193c3c..cb1bbac 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -113,7 +113,10 @@ The placeholders are:
- '%cD': committer date, RFC2822 style
- '%cr': committer date, relative
- '%ct': committer date, UNIX timestamp
-- '%ci': committer date, ISO 8601 format
+- '%ci': committer date, ISO 8601 format, long YYYY-MM-DD HH:MM:SS TZ
+- '%cIM': committer date, ISO 8601 format, short YYYY-MM-DD HH:MM
+- '%cIS': committer date, ISO 8601 format, short YYYY-MM-DD HH:MM:SS
+- '%cID': committer date, ISO 8601 format, short YYYY-MM-DD
- '%e': encoding
- '%s': subject
- '%b': body
diff --git a/cache.h b/cache.h
index 549f4bb..1fae94a 100644
--- a/cache.h
+++ b/cache.h
@@ -444,6 +444,9 @@ enum date_mode {
DATE_SHORT,
DATE_LOCAL,
DATE_ISO8601,
+ DATE_ISO8601_YYYYMMDD,
+ DATE_ISO8601_YYYYMMDDHHMM,
+ DATE_ISO8601_YYYYMMDDHHMMSS,
DATE_RFC2822
};diff --git a/date.c b/date.c
index 8f70500..ded9caa 100644
--- a/date.c
+++ b/date.c
@@ -144,6 +144,23 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)
tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec,
tz);
+ else if (mode == DATE_ISO8601_YYYYMMDD)
+ sprintf(timebuf, "%04d-%02d-%02d",
+ tm-...
I think this "default" is not quite nice. If you want to
support down-to-hour, you'd beter explicitly support 'H'.
"default:" should error out, saying "Ah, oh, sorry, I do not
support %cIX (yet)".Otherwise, it casts the set of truncated ISO 8601 date format we
supports in stone. People would depend on being able to say
"%cIhour" and a new implementation cannot introduce %cIh
modifier that means something.But I do not like the idea of adding more short-hand format this
way. I think we would very much prefer, instead of piling hacks
on top of the originally supported "minimum set", to introduce a
truly extensible syntax, like:%cT(flexible formatting specification for committer time)
or even
%c(flexible formatting specification for committer info)
and that specification may say which field to format with what
prettiness. For example:%c(name|initial) %c(time|local,HH:MM) %c(time|gmt,HH) <%c(email)>
might say:
JCH 15:00 23 <gitster@pobox.com>
(23 is because US/Pacific is 8 hours behind right now).
Of course, %a(likewise for author time) can be defined the same
way.
-
[resent, sorry]
I concur, but pretty-please make it a super set of
date(1) to the extent possible. It will lessen the
confusion.Maybe something like "%c(%Y-%m-%d %H:%M) ...", eg.
such
that if `date +<format>' is legal, so is
"%c(<format>)".Tommy
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
-
Please read what you are replying to again. If you said the
above with %cT(...), it might have made some sense (but then how
are you differentiate between local and original timezone?), but
%c(...) needs to show not just the timestamp.-
