summaryrefslogtreecommitdiff
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2011-02-16 08:52:36 +0000
committerMans Rullgard <mans@mansr.com>2011-02-16 23:39:56 +0000
commitf6c7375a175ac649558aefab14f3895b2cb469aa (patch)
tree759bc4cc9757e5d1d9ab5d0cb661c96862d87737 /libavformat/utils.c
parent610219a598095f938705f200dfe3946455ef871a (diff)
downloadffmpeg-f6c7375a175ac649558aefab14f3895b2cb469aa.tar.gz
Deprecate parse_date() in favor of av_parse_time().
The new av_parse_time() is created in libavutil/parseutils.h, all the internal functions used by parse_date are moved to libavutil/parseutils.c and made static. Signed-off-by: Mans Rullgard <mans@mansr.com>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c124
1 files changed, 8 insertions, 116 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index b325d06276..acac406bf6 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3380,124 +3380,16 @@ uint64_t ff_ntp_time(void)
return (av_gettime() / 1000) * 1000 + NTP_OFFSET_US;
}
-int64_t parse_date(const char *datestr, int duration)
-{
- const char *p;
- int64_t t;
- struct tm dt;
- int i;
- static const char * const date_fmt[] = {
- "%Y-%m-%d",
- "%Y%m%d",
- };
- static const char * const time_fmt[] = {
- "%H:%M:%S",
- "%H%M%S",
- };
- const char *q;
- int is_utc, len;
- char lastch;
- int negative = 0;
-
-#undef time
- time_t now = time(0);
-
- len = strlen(datestr);
- if (len > 0)
- lastch = datestr[len - 1];
- else
- lastch = '\0';
- is_utc = (lastch == 'z' || lastch == 'Z');
-
- memset(&dt, 0, sizeof(dt));
-
- p = datestr;
- q = NULL;
- if (!duration) {
- if (!strncasecmp(datestr, "now", len))
- return (int64_t) now * 1000000;
-
- /* parse the year-month-day part */
- for (i = 0; i < FF_ARRAY_ELEMS(date_fmt); i++) {
- q = small_strptime(p, date_fmt[i], &dt);
- if (q) {
- break;
- }
- }
-
- /* if the year-month-day part is missing, then take the
- * current year-month-day time */
- if (!q) {
- if (is_utc) {
- dt = *gmtime(&now);
- } else {
- dt = *localtime(&now);
- }
- dt.tm_hour = dt.tm_min = dt.tm_sec = 0;
- } else {
- p = q;
- }
-
- if (*p == 'T' || *p == 't' || *p == ' ')
- p++;
-
- /* parse the hour-minute-second part */
- for (i = 0; i < FF_ARRAY_ELEMS(time_fmt); i++) {
- q = small_strptime(p, time_fmt[i], &dt);
- if (q) {
- break;
- }
- }
- } else {
- /* parse datestr as a duration */
- if (p[0] == '-') {
- negative = 1;
- ++p;
- }
- /* parse datestr as HH:MM:SS */
- q = small_strptime(p, time_fmt[0], &dt);
- if (!q) {
- /* parse datestr as S+ */
- dt.tm_sec = strtol(p, (char **)&q, 10);
- if (q == p)
- /* the parsing didn't succeed */
- return INT64_MIN;
- dt.tm_min = 0;
- dt.tm_hour = 0;
- }
- }
-
- /* Now we have all the fields that we can get */
- if (!q) {
- return INT64_MIN;
- }
-
- if (duration) {
- t = dt.tm_hour * 3600 + dt.tm_min * 60 + dt.tm_sec;
- } else {
- dt.tm_isdst = -1; /* unknown */
- if (is_utc) {
- t = mktimegm(&dt);
- } else {
- t = mktime(&dt);
- }
- }
-
- t *= 1000000;
+#if FF_API_PARSE_DATE
+#include "libavutil/parseutils.h"
- /* parse the .m... part */
- if (*q == '.') {
- int val, n;
- q++;
- for (val = 0, n = 100000; n >= 1; n /= 10, q++) {
- if (!isdigit(*q))
- break;
- val += n * (*q - '0');
- }
- t += val;
- }
- return negative ? -t : t;
+int64_t parse_date(const char *timestr, int duration)
+{
+ int64_t timeval;
+ av_parse_time(&timeval, timestr, duration);
+ return timeval;
}
+#endif
int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info)
{