static tt_time_t tt_ParseTime( const char *s ) { tt_time_t t = {-1, 0}; unsigned h1 = 0, m1 = 0, s1 = 0, d1 = 0; char c = 0; /* Clock time */ if( sscanf( s, "%u:%u:%u%c%u", &h1, &m1, &s1, &c, &d1 ) == 5 || tt_ScanReset( &h1, &m1, &s1, &c, &d1 ) || sscanf( s, "%u:%u:%u", &h1, &m1, &s1 ) == 3 || tt_ScanReset( &h1, &m1, &s1, &c, &d1 ) ) { t.base = CLOCK_FREQ * (h1 * 3600 + m1 * 60 + s1); if( c == '.' && d1 > 0 ) { unsigned i_den = 1; for( const char *p = strchr( s, '.' ) + 1; *p; p++ ) i_den *= 10; t.base += CLOCK_FREQ * d1 / i_den; } else if( c == ':' ) { t.frames = d1; } } else /* Offset Time */ { char *psz_end = (char *) s; double v = us_strtod( s, &psz_end ); if( psz_end != s && *psz_end ) { if( *psz_end == 'm' ) { if( *(psz_end + 1) == 's' ) t.base = 1000 * v; else t.base = CLOCK_FREQ * 60 * v; } else if( *psz_end == 's' ) { t.base = CLOCK_FREQ * v; } else if( *psz_end == 'h' ) { t.base = CLOCK_FREQ * v * 3600; } else if( *psz_end == 'f' ) { t.base = 0; t.frames = v; } //else if( *psz_end == 't' ); } } return t; }
/** * us_atof() has the same prototype as ANSI C atof() but it expects a dot * as decimal separator, regardless of the system locale. */ double us_atof( const char *str ) { return us_strtod( str, NULL ); }