Code

make time paring more robust ... it can now deal with
authoroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Sun, 22 Oct 2006 21:20:45 +0000 (21:20 +0000)
committeroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Sun, 22 Oct 2006 21:20:45 +0000 (21:20 +0000)
time date
date time
time date + xxx
date time + xxx

git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@908 a5681a0c-68f1-0310-ab6d-d61299d08faa

src/parsetime.c

index f1958430224ef73487e8660001334315ca84d38a..47ddbbfc7a3fe95bfccb54eb1e823e328b2958b6 100644 (file)
@@ -837,9 +837,23 @@ parsetime(const char *tspec, struct rrd_time_value *ptv)
 
     /* Only absolute time specifications below */
     case NUMBER:
-           try(tod(ptv))
-            try(day(ptv))
-            try(tod(ptv))
+           {
+             long hour_sv = ptv->tm.tm_hour;
+             long year_sv = ptv->tm.tm_year;
+              ptv->tm.tm_hour = 30;
+              ptv->tm.tm_year = 30000;
+             try(tod(ptv))
+             try(day(ptv))
+             if ( ptv->tm.tm_hour == 30 &&  ptv->tm.tm_year != 30000 ){
+               try(tod(ptv))
+              }
+             if ( ptv->tm.tm_hour == 30 ){
+               ptv->tm.tm_hour = hour_sv;
+              }
+             if ( ptv->tm.tm_hour == 30000 ){
+               ptv->tm.tm_year = year_sv;
+              }
+           };      
             break;
     /* fix month parsing */
     case JAN: case FEB: case MAR: case APR: case MAY: case JUN: