Commit 0739179b authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '108f2f38'

* commit '108f2f38':
  parseutils: Extend small_strptime to be used in avformat

Conflicts:
	libavutil/parseutils.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 6fd300ac 108f2f38
...@@ -465,68 +465,71 @@ char *av_small_strptime(const char *p, const char *fmt, struct tm *dt) ...@@ -465,68 +465,71 @@ char *av_small_strptime(const char *p, const char *fmt, struct tm *dt)
{ {
int c, val; int c, val;
for(;;) { while((c = *fmt++)) {
/* consume time string until a non whitespace char is found */ if (c != '%') {
while (av_isspace(*fmt)) { if (av_isspace(c))
while (av_isspace(*p)) for (; *p && av_isspace(*p); p++);
p++; else if (*p != c)
fmt++; return NULL;
else p++;
continue;
} }
c = *fmt++; c = *fmt++;
if (c == '\0') { switch(c) {
return (char *)p; case 'H':
} else if (c == '%') { case 'J':
c = *fmt++; val = date_get_num(&p, 0, c == 'H' ? 23 : INT_MAX, 2);
switch(c) {
case 'H': if (val == -1)
case 'J':
val = date_get_num(&p, 0, c == 'H' ? 23 : INT_MAX, 2);
if (val == -1)
return NULL;
dt->tm_hour = val;
break;
case 'M':
val = date_get_num(&p, 0, 59, 2);
if (val == -1)
return NULL;
dt->tm_min = val;
break;
case 'S':
val = date_get_num(&p, 0, 59, 2);
if (val == -1)
return NULL;
dt->tm_sec = val;
break;
case 'Y':
val = date_get_num(&p, 0, 9999, 4);
if (val == -1)
return NULL;
dt->tm_year = val - 1900;
break;
case 'm':
val = date_get_num(&p, 1, 12, 2);
if (val == -1)
return NULL;
dt->tm_mon = val - 1;
break;
case 'd':
val = date_get_num(&p, 1, 31, 2);
if (val == -1)
return NULL;
dt->tm_mday = val;
break;
case '%':
goto match;
default:
return NULL; return NULL;
} dt->tm_hour = val;
} else { break;
match: case 'M':
if (c != *p) val = date_get_num(&p, 0, 59, 2);
if (val == -1)
return NULL; return NULL;
p++; dt->tm_min = val;
break;
case 'S':
val = date_get_num(&p, 0, 59, 2);
if (val == -1)
return NULL;
dt->tm_sec = val;
break;
case 'Y':
val = date_get_num(&p, 0, 9999, 4);
if (val == -1)
return NULL;
dt->tm_year = val - 1900;
break;
case 'm':
val = date_get_num(&p, 1, 12, 2);
if (val == -1)
return NULL;
dt->tm_mon = val - 1;
break;
case 'd':
val = date_get_num(&p, 1, 31, 2);
if (val == -1)
return NULL;
dt->tm_mday = val;
break;
case 'T':
p = av_small_strptime(p, "%H:%M:%S", dt);
if (!p)
return NULL;
break;
case '%':
if (*p++ != '%')
return NULL;
break;
default:
return NULL;
} }
} }
return (char*)p;
} }
time_t av_timegm(struct tm *tm) time_t av_timegm(struct tm *tm)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment