diff --git a/asc2log.c b/asc2log.c index 4935de0..de619c0 100644 --- a/asc2log.c +++ b/asc2log.c @@ -323,6 +323,7 @@ void eval_canfd(char* buf, struct timeval *date_tvp, char timestamps, int dplace int get_date(struct timeval *tv, char *date) { struct tm tms; + unsigned int msecs = 0; if (strcasestr(date, " pm ") != NULL) { /* assume EN/US date due to existing am/pm field */ @@ -338,6 +339,8 @@ int get_date(struct timeval *tv, char *date) { before parsing the real year value (hack) */ if (!strptime(date, "%B %d %I:%M:%S.%Y %p %Y", &tms)) return 1; + else + sscanf(date, "%*s %*d %*d:%*d:%*d.%3u ", &msecs); } } else { @@ -354,14 +357,17 @@ int get_date(struct timeval *tv, char *date) { before parsing the real year value (hack) */ if (!strptime(date, "%B %d %H:%M:%S.%Y %Y", &tms)) return 1; + else + sscanf(date, "%*s %*d %*d:%*d:%*d.%3u ", &msecs); } } - //printf("h %d m %d s %d d %d m %d y %d\n", - //tms.tm_hour, tms.tm_min, tms.tm_sec, + //printf("h %d m %d s %d ms %03d d %d m %d y %d\n", + //tms.tm_hour, tms.tm_min, tms.tm_sec, msecs, //tms.tm_mday, tms.tm_mon+1, tms.tm_year+1900); tv->tv_sec = mktime(&tms); + tv->tv_usec = msecs * 1000; if (tv->tv_sec < 0) return 1;