[[[
* (subversion/libsvn_subr/date.c): Relax the date template parser to 
    allow for user input without leading zeros in the Month, Day and 
    Hour for templates which have separators.
    Check to make sure the day is not less than 1.

* (subversion/tests/libsvn_subr/time-test.c): Add tests to verify the
    above changes.
]]]
Index: subversion/libsvn_subr/date.c
===================================================================
--- subversion/libsvn_subr/date.c	(revision 15393)
+++ subversion/libsvn_subr/date.c	(working copy)
@@ -204,13 +204,13 @@
     return svn_error_wrap_apr (apr_err, _("Can't manipulate current date"));
 
   if (template_match (&expt, &localtz, /* ISO-8601 extended, date only */
-                      "YYYY-MM-DD",
+                      "YYYY-M[M]-D[D]",
                       text)
       || template_match (&expt, &localtz, /* ISO-8601 extended, UTC */
-                      "YYYY-MM-DDThh:mm[:ss[.u[u[u[u[u[u][Z]",
+                      "YYYY-M[M]-D[D]Th[h]:mm[:ss[.u[u[u[u[u[u][Z]",
                       text)
       || template_match (&expt, &localtz, /* ISO-8601 extended, with offset */
-                         "YYYY-MM-DDThh:mm[:ss[.u[u[u[u[u[u]+OO[:oo]",
+                         "YYYY-M[M]-D[D]Th[h]:mm[:ss[.u[u[u[u[u[u]+OO[:oo]",
                          text)
       || template_match (&expt, &localtz, /* ISO-8601 basic, date only */
                          "YYYYMMDD",
@@ -222,17 +222,17 @@
                          "YYYYMMDDThhmm[ss[.u[u[u[u[u[u]+OO[oo]",
                          text)
       || template_match (&expt, &localtz, /* "svn log" format */
-                         "YYYY-MM-DD hh:mm[:ss[.u[u[u[u[u[u][ +OO[oo]",
+                         "YYYY-M[M]-D[D] h[h]:mm[:ss[.u[u[u[u[u[u][ +OO[oo]",
                          text)
       || template_match (&expt, &localtz, /* GNU date's iso-8601 */
-                         "YYYY-MM-DDThh:mm[:ss[.u[u[u[u[u[u]+OO[oo]",
+                         "YYYY-M[M]-D[D]Th[h]:mm[:ss[.u[u[u[u[u[u]+OO[oo]",
                          text))
     {
       expt.tm_year -= 1900;
       expt.tm_mon -= 1;
     }
   else if (template_match (&expt, &localtz, /* Just a time */
-                           "hh:mm[:ss[.u[u[u[u[u[u]",
+                           "h[h]:mm[:ss[.u[u[u[u[u[u]",
                            text))
     {
       expt.tm_year = expnow.tm_year;
@@ -245,6 +245,7 @@
   /* Range validation, allowing for leap seconds */
   if (expt.tm_mon < 0 || expt.tm_mon > 11
       || expt.tm_mday > valid_days_by_month[expt.tm_mon]
+      || expt.tm_mday < 1
       || expt.tm_hour > 23
       || expt.tm_min > 59
       || expt.tm_sec > 60)
Index: subversion/tests/libsvn_subr/time-test.c
===================================================================
--- subversion/tests/libsvn_subr/time-test.c	(revision 15393)
+++ subversion/tests/libsvn_subr/time-test.c	(working copy)
@@ -201,9 +201,11 @@
    svn_parse_date result it in the local time zone and verify that
    against the desired values. */
 static struct date_test localtz_tests[] = {
-  /* YYYY-MM-DD */
+  /* YYYY-M[M]-D[D] */
   { "2013-01-25",                      2013,  1, 25,  0,  0,  0,      0 },
-  /* YYYY-MM-DD[Thh:mm[:ss[.u[u[u[u[u[u] */
+  { "2013-1-25",                       2013,  1, 25,  0,  0,  0,      0 },
+  { "2013-01-2",                       2013,  1,  2,  0,  0,  0,      0 },
+  /* YYYY-M[M]-D[D][Th[h]:mm[:ss[.u[u[u[u[u[u] */
   { "2015-04-26T00:01:59.652655",      2015,  4, 26,  0,  1, 59, 652655 },
   { "2034-07-20T17:03:36.11379",       2034,  7, 20, 17,  3, 36, 113790 },
   { "1975-10-29T17:23:56.3859",        1975, 10, 29, 17, 23, 56, 385900 },
@@ -212,14 +214,18 @@
   { "2017-01-28T07:21:13.2",           2017,  1, 28,  7, 21, 13, 200000 },
   { "2013-05-18T13:52:49",             2013,  5, 18, 13, 52, 49,      0 },
   { "2020-05-14T15:28",                2020,  5, 14, 15, 28,  0,      0 },
+  { "2032-05-14T7:28",                 2032,  5, 14,  7, 28,  0,      0 },
+  { "2020-5-14T15:28",                 2020,  5, 14, 15, 28,  0,      0 },
+  { "2020-05-1T15:28",                 2020,  5,  1, 15, 28,  0,      0 },
   /* YYYYMMDD */
   { "20100226",                        2010,  2, 26,  0,  0,  0,      0 },
   /* YYYYMMDD[Thhmm[ss[.u[u[u[u[u[u] */
   { "19860214T050745.6",               1986,  2, 14,  5,  7, 45, 600000 },
   { "20230219T0045",                   2023,  2, 19,  0, 45,  0,      0 },
-  /* YYYY-MM-DD hh:mm[:ss[.u[u[u[u[u[u] */
+  /* YYYY-M[M]-D[D] [h]h:mm[:ss[.u[u[u[u[u[u] */
   { "1975-07-11 06:31:49.749504",      1975,  7, 11,  6, 31, 49, 749504 },
   { "2037-05-06 00:08",                2037,  5,  6,  0,  8,  0,      0 },
+  { "2037-5-6 7:01",                  2037,  5,  6,  7,  1,  0,      0 },
   /* Make sure we can do leap days. */
   { "1976-02-29",                      1976, 02, 29,  0,  0,  0,      0 },
   { "2000-02-29",                      2000, 02, 29,  0,  0,  0,      0 },
@@ -263,6 +269,7 @@
   "2000-00-02",           /* Invalid month */
   "2000-13-02",           /* Invalid month */
   "2000-01-32",           /* Invalid day */
+  "2000-01-00",           /* Invalid day */
   "1999-02-29",           /* Invalid leap day */
   "2000-01-01 24:00:00",  /* Invalid hour */
   "2000-01-01 00:60:00",  /* Invalid minute */
