Code

Revert "t5516: test update of local refs on push"
[git.git] / date.c
diff --git a/date.c b/date.c
index 45b0b1deb36672d9a27ac98c95c92884f8d80cf8..8f7050027053a4e2390097e341327b117404c26a 100644 (file)
--- a/date.c
+++ b/date.c
@@ -584,6 +584,26 @@ int parse_date(const char *date, char *result, int maxlen)
        return date_string(then, offset, result, maxlen);
 }
 
+enum date_mode parse_date_format(const char *format)
+{
+       if (!strcmp(format, "relative"))
+               return DATE_RELATIVE;
+       else if (!strcmp(format, "iso8601") ||
+                !strcmp(format, "iso"))
+               return DATE_ISO8601;
+       else if (!strcmp(format, "rfc2822") ||
+                !strcmp(format, "rfc"))
+               return DATE_RFC2822;
+       else if (!strcmp(format, "short"))
+               return DATE_SHORT;
+       else if (!strcmp(format, "local"))
+               return DATE_LOCAL;
+       else if (!strcmp(format, "default"))
+               return DATE_NORMAL;
+       else
+               die("unknown date format %s", format);
+}
+
 void datestamp(char *buf, int bufsize)
 {
        time_t now;
@@ -660,6 +680,14 @@ static void date_am(struct tm *tm, int *num)
        tm->tm_hour = (hour % 12);
 }
 
+static void date_never(struct tm *tm, int *num)
+{
+       tm->tm_mon = tm->tm_wday = tm->tm_yday
+               = tm->tm_hour = tm->tm_min = tm->tm_sec = 0;
+       tm->tm_year = 70;
+       tm->tm_mday = 1;
+}
+
 static const struct special {
        const char *name;
        void (*fn)(struct tm *, int *);
@@ -670,6 +698,7 @@ static const struct special {
        { "tea", date_tea },
        { "PM", date_pm },
        { "AM", date_am },
+       { "never", date_never },
        { NULL }
 };