parseutils: Make av_small_strptime public

And use it in libavformat.

Based on a similar patch by Stefano Sabatini <stefasab@gmail.com>.
This commit is contained in:
Luca Barbato
2015-04-06 01:45:37 +02:00
parent 108f2f381a
commit 27f2746282
6 changed files with 42 additions and 17 deletions

View File

@@ -2902,21 +2902,14 @@ int ff_find_stream_index(AVFormatContext *s, int id)
int64_t ff_iso8601_to_unix_time(const char *datestr)
{
#if HAVE_STRPTIME
struct tm time1 = { 0 }, time2 = { 0 };
char *ret1, *ret2;
ret1 = strptime(datestr, "%Y - %m - %d %T", &time1);
ret2 = strptime(datestr, "%Y - %m - %dT%T", &time2);
ret1 = av_small_strptime(datestr, "%Y - %m - %d %T", &time1);
ret2 = av_small_strptime(datestr, "%Y - %m - %dT%T", &time2);
if (ret2 && !ret1)
return av_timegm(&time2);
else
return av_timegm(&time1);
#else
av_log(NULL, AV_LOG_WARNING,
"strptime() unavailable on this system, cannot convert "
"the date string.\n");
return 0;
#endif
}
int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id,