Add explanatory comments to the parse_date function.
patch by Stefano Sabatini, stefano.sabatini-lala poste it Originally committed as revision 10525 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
dbd255cda1
commit
a8f70d72c3
@ -2579,6 +2579,7 @@ int64_t parse_date(const char *datestr, int duration)
|
|||||||
p = datestr;
|
p = datestr;
|
||||||
q = NULL;
|
q = NULL;
|
||||||
if (!duration) {
|
if (!duration) {
|
||||||
|
/* parse the year-month-day part */
|
||||||
for (i = 0; i < sizeof(date_fmt) / sizeof(date_fmt[0]); i++) {
|
for (i = 0; i < sizeof(date_fmt) / sizeof(date_fmt[0]); i++) {
|
||||||
q = small_strptime(p, date_fmt[i], &dt);
|
q = small_strptime(p, date_fmt[i], &dt);
|
||||||
if (q) {
|
if (q) {
|
||||||
@ -2586,6 +2587,8 @@ int64_t parse_date(const char *datestr, int duration)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if the year-month-day part is missing, then take the
|
||||||
|
* current year-month-day time */
|
||||||
if (!q) {
|
if (!q) {
|
||||||
if (is_utc) {
|
if (is_utc) {
|
||||||
dt = *gmtime(&now);
|
dt = *gmtime(&now);
|
||||||
@ -2600,6 +2603,7 @@ int64_t parse_date(const char *datestr, int duration)
|
|||||||
if (*p == 'T' || *p == 't' || *p == ' ')
|
if (*p == 'T' || *p == 't' || *p == ' ')
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
|
/* parse the hour-minute-second part */
|
||||||
for (i = 0; i < sizeof(time_fmt) / sizeof(time_fmt[0]); i++) {
|
for (i = 0; i < sizeof(time_fmt) / sizeof(time_fmt[0]); i++) {
|
||||||
q = small_strptime(p, time_fmt[i], &dt);
|
q = small_strptime(p, time_fmt[i], &dt);
|
||||||
if (q) {
|
if (q) {
|
||||||
@ -2607,12 +2611,15 @@ int64_t parse_date(const char *datestr, int duration)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
/* parse datestr as a duration */
|
||||||
if (p[0] == '-') {
|
if (p[0] == '-') {
|
||||||
negative = 1;
|
negative = 1;
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
|
/* parse datestr as HH:MM:SS */
|
||||||
q = small_strptime(p, time_fmt[0], &dt);
|
q = small_strptime(p, time_fmt[0], &dt);
|
||||||
if (!q) {
|
if (!q) {
|
||||||
|
/* parse datestr as S+ */
|
||||||
dt.tm_sec = strtol(p, (char **)&q, 10);
|
dt.tm_sec = strtol(p, (char **)&q, 10);
|
||||||
dt.tm_min = 0;
|
dt.tm_min = 0;
|
||||||
dt.tm_hour = 0;
|
dt.tm_hour = 0;
|
||||||
@ -2640,6 +2647,7 @@ int64_t parse_date(const char *datestr, int duration)
|
|||||||
|
|
||||||
t *= 1000000;
|
t *= 1000000;
|
||||||
|
|
||||||
|
/* parse the .m... part */
|
||||||
if (*q == '.') {
|
if (*q == '.') {
|
||||||
int val, n;
|
int val, n;
|
||||||
q++;
|
q++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user