Use RFC2822 dates from "git fmt-patch".
Still Work-in-progress git fmt-patch (should it be known as format-patch-ng?) is matched with the fix made by Huw Davies in 262a6ef76a1dde97ab50d79fa5cd6d3f9f125765 commit to use RFC2822 date format. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
May 1, 2006 at 01:44 UTC
2a3870432395e78c82a870bf1a177b8d5b8fbdf0
3 files changed
+28
-5
cache.h
+1
@@ -249,6 +249,7 @@ extern void *read_object_with_reference(const unsigned char *sha1,
249
unsigned char *sha1_ret);
250
251
const char *show_date(unsigned long time, int timezone);
252
+const char *show_rfc2822_date(unsigned long time, int timezone);
253
int parse_date(const char *date, char *buf, int bufsize);
254
void datestamp(char *buf, int bufsize);
255
unsigned long approxidate(const char *);
commit.c
+2
-1
@@ -442,7 +442,8 @@ static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf, const c
442
ret += sprintf(buf + ret, "Date: %s\n", show_date(time, tz));
443
break;
444
case CMIT_FMT_EMAIL:
445
- ret += sprintf(buf + ret, "Date: %s\n", show_date(time, tz));
445
+ ret += sprintf(buf + ret, "Date: %s\n",
446
+ show_rfc2822_date(time, tz));
447
break;
448
case CMIT_FMT_FULLER:
449
ret += sprintf(buf + ret, "%sDate: %s\n", what, show_date(time, tz));
date.c
+25
-4
@@ -42,18 +42,24 @@ static const char *weekday_names[] = {
42
* thing, which means that tz -0100 is passed in as the integer -100,
43
* even though it means "sixty minutes off"
44
*/
45
-const char *show_date(unsigned long time, int tz)
45
+static struct tm *time_to_tm(unsigned long time, int tz)
46
{
47
- struct tm *tm;
47
time_t t;
49
- static char timebuf[200];
48
int minutes;
49
50
minutes = tz < 0 ? -tz : tz;
51
minutes = (minutes / 100)*60 + (minutes % 100);
52
minutes = tz < 0 ? -minutes : minutes;
53
t = time + minutes * 60;
56
- tm = gmtime(&t);
54
+ return gmtime(&t);
55
+}
56
+
57
+const char *show_date(unsigned long time, int tz)
58
+{
59
+ struct tm *tm;
60
+ static char timebuf[200];
61
+
62
+ tm = time_to_tm(time, tz);
63
if (!tm)
64
return NULL;
65
sprintf(timebuf, "%.3s %.3s %d %02d:%02d:%02d %d %+05d",
@@ -65,6 +71,21 @@ const char *show_date(unsigned long time, int tz)
71
return timebuf;
72
}
73
74
+const char *show_rfc2822_date(unsigned long time, int tz)
75
+{
76
+ struct tm *tm;
77
+ static char timebuf[200];
78
+
79
+ tm = time_to_tm(time, tz);
80
+ if (!tm)
81
+ return NULL;
82
+ sprintf(timebuf, "%.3s, %d %.3s %d %02d:%02d:%02d %+05d",
83
+ weekday_names[tm->tm_wday], tm->tm_mday,
84
+ month_names[tm->tm_mon], tm->tm_year + 1900,
85
+ tm->tm_hour, tm->tm_min, tm->tm_sec, tz);
86
+ return timebuf;
87
+}
88
+
89
/*
90
* Check these. And note how it doesn't do the summer-time conversion.
91
*