--- time.c.orig Thu Aug 19 23:35:30 1999 +++ time.c Tue Nov 20 15:34:56 2001 @@ -47,6 +47,7 @@ * prevents use of relative times. */ +#define ENABLE_MICRO_SEC /* use tm_zone as micro seconds */ #include "plot.h" @@ -97,6 +98,7 @@ static int gdysize __PROTO((int yr)); + static char * read_int(s, nr, d) char *s; @@ -154,6 +156,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; @@ -260,7 +265,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; default: @@ -269,7 +285,7 @@ fmt++; } - FPRINTF((stderr, "read date-time : %d/%d/%d:%d:%d:%d\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 : %d/%d/%d:%d:%d:%d.%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 @@ -573,6 +589,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') { @@ -619,8 +640,11 @@ dsec += tm->tm_min; dsec *= 60.0; dsec += tm->tm_sec; +#ifdef ENABLE_MICRO_SEC /*[*/ + dsec += (int)tm->tm_zone / 1e6; +#endif /*]*/ - FPRINTF((stderr, "broken-down time : %d/%d/%d:%d:%d:%d = %g seconds\n", tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec, dsec)); + FPRINTF((stderr, "broken-down time : %d/%d/%d:%d:%d:%d.%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); } @@ -666,6 +690,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;