git-merge-cache -o does all the automerges in a single shot
[git.git] / date.c
diff --git a/date.c b/date.c
index 5ee4984..7371bc1 100644 (file)
--- a/date.c
+++ b/date.c
@@ -39,6 +39,34 @@ static const char *weekday_names[] = {
 };
 
 /*
+ * The "tz" thing is passed in as this strange "decimal parse of tz"
+ * thing, which means that tz -0100 is passed in as the integer -100,
+ * even though it means "sixty minutes off"
+ */
+const char *show_date(unsigned long time, int tz)
+{
+       struct tm *tm;
+       time_t t;
+       static char timebuf[200];
+       int minutes;
+
+       minutes = tz < 0 ? -tz : tz;
+       minutes = (tz / 100)*60 + (tz % 100);
+       minutes = tz < 0 ? -minutes : minutes;
+       t = time - minutes * 60;
+       tm = gmtime(&t);
+       if (!tm)
+               return NULL;
+       sprintf(timebuf, "%.3s %.3s %d %02d:%02d:%02d %d %+05d",
+               weekday_names[tm->tm_wday],
+               month_names[tm->tm_mon],
+               tm->tm_mday,
+               tm->tm_hour, tm->tm_min, tm->tm_sec,
+               tm->tm_year + 1900, tz);
+       return timebuf;
+}
+
+/*
  * Check these. And note how it doesn't do the summer-time conversion.
  *
  * In my world, it's always summer, and things are probably a bit off
@@ -114,6 +142,15 @@ static int match_string(const char *date, const char *str)
        return i;
 }
 
+static int skip_alpha(const char *date)
+{
+       int i = 0;
+       do {
+               i++;
+       } while (isalpha(date[i]));
+       return i;
+}
+
 /*
 * Parse month, weekday, or timezone name
 */
@@ -153,8 +190,14 @@ static int match_alpha(const char *date, struct tm *tm, int *offset)
                }
        }
 
+       if (match_string(date, "PM") == 2) {
+               if (tm->tm_hour > 0 && tm->tm_hour < 12)
+                       tm->tm_hour += 12;
+               return 2;
+       }
+
        /* BAD CRAP */
-       return 0;
+       return skip_alpha(date);
 }
 
 static int is_date(int year, int month, int day, struct tm *tm)
@@ -332,14 +375,13 @@ static int match_tz(char *date, int *offp)
         * a valid minute. We might want to check that the minutes
         * are divisible by 30 or something too.
         */
-       if (min >= 60 || n < 3)
-               return 0;
-
-       offset = hour*60+min;
-       if (*date == '-')
-               offset = -offset;
+       if (min < 60 && n > 2) {
+               offset = hour*60+min;
+               if (*date == '-')
+                       offset = -offset;
 
-       *offp = offset;
+               *offp = offset;
+       }
        return end - date;
 }