[FFmpeg-devel] [PATCH 02/12] avutil/parseutils: accept everything in av_parse_time that ff_iso8601_to_unix_time accepts

Marton Balint cus at passwd.hu
Sat Feb 6 20:13:13 CET 2016


Signed-off-by: Marton Balint <cus at passwd.hu>
---
 libavutil/parseutils.c    | 8 ++++++--
 tests/ref/fate/parseutils | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
index fd8cf2b..0efc608 100644
--- a/libavutil/parseutils.c
+++ b/libavutil/parseutils.c
@@ -565,7 +565,7 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration)
     int today = 0, negative = 0, microseconds = 0;
     int i;
     static const char * const date_fmt[] = {
-        "%Y-%m-%d",
+        "%Y - %m - %d",
         "%Y%m%d",
     };
     static const char * const time_fmt[] = {
@@ -600,8 +600,11 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration)
         }
         p = q;
 
-        if (*p == 'T' || *p == 't' || *p == ' ')
+        if (*p == 'T' || *p == 't')
             p++;
+        else
+            while (av_isspace(*p))
+                p++;
 
         /* parse the hour-minute-second part */
         for (i = 0; i < FF_ARRAY_ELEMS(time_fmt); i++) {
@@ -860,6 +863,7 @@ int main(void)
             "now",
             "12:35:46",
             "2000-12-20 0:02:47.5z",
+            "2012 - 02-22  17:44:07",
             "2000-12-20T010247.6",
         };
         static const char * const duration_string[] = {
diff --git a/tests/ref/fate/parseutils b/tests/ref/fate/parseutils
index 176140c..8ba20b3 100644
--- a/tests/ref/fate/parseutils
+++ b/tests/ref/fate/parseutils
@@ -74,6 +74,7 @@ Testing av_parse_time()
 now                      ->     1331972053.200000 = 2012-03-17T08:14:13Z
 12:35:46                 ->     1331984146.000000 = 2012-03-17T11:35:46Z
 2000-12-20 0:02:47.5z    ->      977270567.500000 = 2000-12-20T00:02:47Z
+2012 - 02-22  17:44:07   ->     1329929047.000000 = 2012-02-22T16:44:07Z
 2000-12-20T010247.6      ->      977270567.600000 = 2000-12-20T00:02:47Z
 2:34:56.79               ->           +9296790000
 -1:23:45.67              ->           -5025670000
-- 
2.6.2



More information about the ffmpeg-devel mailing list