--- src/time.c.orig Wed Apr 14 02:24:02 2004 +++ src/time.c Tue Jul 20 09:38:25 2004 @@ -47,6 +47,7 @@ * prevents use of relative times. */ +#define ENABLE_MICRO_SEC /* use tm_zone as micro seconds */ #include "gp_time.h" @@ -172,6 +173,9 @@ date = yday = 0; tm->tm_mday = 1; tm->tm_mon = tm->tm_hour = tm->tm_min = tm->tm_sec = 0; +#ifdef ENABLE_MICRO_SEC /*[*/ + tm->tm_zone = (char *)0; +#endif /*]*/ /* make relative times work (user-defined tic step) */ tm->tm_year = ZERO_YEAR; @@ -280,7 +284,18 @@ break; case 'S': - s = read_int(s, 2, &tm->tm_sec); + s = read_int(s, 9, &tm->tm_sec); +#ifdef ENABLE_MICRO_SEC /*[*/ + if (*s = '.') { + int usec, n; + char *s0 = s + 1; + s = read_int(s0, 6, &usec); + n = s - s0; /* read n chars */ + while (n++ < 6) + usec *= 10; + tm->tm_zone = (char *)usec; + } +#endif /*]*/ break; /* read EPOCH data @@ -327,7 +342,7 @@ fmt++; } - FPRINTF((stderr, "read date-time : %02d/%02d/%d:%02d:%02d:%02d\n", tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec)); + FPRINTF((stderr, "read date-time : %02d/%02d/%d:%02d:%02d:%02d.%03d\n", tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)tm->tm_zone)); /* now check the date/time entered, normalising if necessary * read_int cannot read a -ve number, but can read %m=0 then decrement @@ -642,6 +657,11 @@ COPY_STRING(tm->tm_zone); break; #endif +#ifdef ENABLE_MICRO_SEC /*[*/ + case 'Z': + FORMAT_STRING(1, 3, (long)tm->tm_zone / 1000); + break; +#endif /*]*/ } /* switch */ while (*s != '\0') { @@ -692,8 +712,11 @@ dsec *= 60.0; dsec += tm->tm_sec; - FPRINTF((stderr, "broken-down time : %02d/%02d/%d:%02d:%02d:%02d = %g seconds\n", tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_hour, - tm->tm_min, tm->tm_sec, dsec)); +#ifdef ENABLE_MICRO_SEC /*[*/ + dsec += (int)tm->tm_zone / 1e6; +#endif /*]*/ + FPRINTF((stderr, "broken-down time : %02d/%02d/%d:%02d:%02d:%02d.%06d = %g seconds\n", tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_hour, + tm->tm_min, tm->tm_sec, (int)tm->tm_zone, dsec)); return (dsec); } @@ -740,6 +763,10 @@ tm->tm_min = (int) l_clock / 60; l_clock -= tm->tm_min * 60; tm->tm_sec = (int) l_clock; +#ifdef ENABLE_MICRO_SEC /*[*/ + l_clock -= tm->tm_sec; + tm->tm_zone = (char *)(int)(l_clock * 1e6 + 0.5); +#endif /*]*/ days = tm->tm_yday;