From 7dff9b30ea0603fe265f9f7da055fc34f5d57d2f Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 20 Feb 2009 14:15:22 -0800 Subject: Support 'raw' date format Talking about --date, one thing I wanted for the 1234567890 date was to get things in the raw format. Sure, you get them with --pretty=raw, but it felt a bit sad that you couldn't just ask for the date in raw format. So here's a throw-away patch (meaning: I won't be re-sending it, because I really don't think it's a big deal) to add "--date=raw". It just prints out the internal raw git format - seconds since epoch plus timezone (put another way: 'date +"%s %z"' format) Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- date.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'date.c') diff --git a/date.c b/date.c index 950b88fdc..d75dff424 100644 --- a/date.c +++ b/date.c @@ -89,6 +89,11 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode) struct tm *tm; static char timebuf[200]; + if (mode == DATE_RAW) { + snprintf(timebuf, sizeof(timebuf), "%lu %+05d", time, tz); + return timebuf; + } + if (mode == DATE_RELATIVE) { unsigned long diff; struct timeval now; @@ -615,6 +620,8 @@ enum date_mode parse_date_format(const char *format) return DATE_LOCAL; else if (!strcmp(format, "default")) return DATE_NORMAL; + else if (!strcmp(format, "raw")) + return DATE_RAW; else die("unknown date format %s", format); } -- cgit v1.2.1