+/** Calculate current time or elapsed time.
+ *
+ * If \a start is NULL, create a timestamp containing Unix timestamp
+ * and microseconds since that second (separated by a period), and
+ * return a string containing that timestamp.
+ *
+ * Otherwise, if \a start does not contain a period, return a string
+ * equal to "0".
+ *
+ * Otherwise, calculate milliseconds elapsed since the Unix time
+ * described in \a start (in the format described above), and return a
+ * string containing that number.
+ *
+ * @todo This should be made into two functions.
+ * @param[in] start Either NULL or a Unix timestamp in
+ * pseudo-floating-point format.
+ * @return A static buffer with contents as described above.
+ */
+char *militime_float(char* start)
+{
+ struct timeval tv;
+ static char timebuf[18];
+ char *p;
+
+ gettimeofday(&tv, NULL);
+ if (start)
+ {
+ if ((p = strchr(start, '.')))
+ {
+ p++;
+ sprintf(timebuf, "%ld",
+ (tv.tv_sec - atoi(start)) * 1000 + (tv.tv_usec - atoi(p)) / 1000);
+ }
+ else
+ strcpy(timebuf, "0");
+ }
+ else
+ sprintf(timebuf, "%ld.%ld", tv.tv_sec, tv.tv_usec);
+ return timebuf;
+}