[FFmpeg-devel] [PATCH] lavf/utils: fix ISO8601 date generation, after the switch to av_small_strptime()

Michael Niedermayer michaelni at gmx.at
Sun Sep 16 15:39:43 CEST 2012


On Sun, Sep 16, 2012 at 03:24:37PM +0200, Stefano Sabatini wrote:
> strptime() seems to be more robust to incorrect specification containing
> spaces.
> 
> Should fix trac ticket #1739.
> ---
>  libavformat/utils.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index c6a9e58..4b6eba8 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -4486,8 +4486,8 @@ int64_t ff_iso8601_to_unix_time(const char *datestr)
>  {
>      struct tm time1 = {0}, time2 = {0};
>      char *ret1, *ret2;
> -    ret1 = av_small_strptime(datestr, "%Y - %m - %d %H:%M:%S", &time1);
> -    ret2 = av_small_strptime(datestr, "%Y - %m - %dT%H:%M:%S", &time2);
> +    ret1 = av_small_strptime(datestr, "%Y-%m-%d %H:%M:%S", &time1);
> +    ret2 = av_small_strptime(datestr, "%Y-%m-%dT%H:%M:%S", &time2);
>      if (ret2 && !ret1)
>          return av_timegm(&time2);
>      else

av_small_strptime() should be fixed otherwise i think we should use
strptime() as av_small_strptime() is not even compliant for a subset
of the format specifers

POSIX about strptime:
A conversion specification composed of white-space characters is executed by scanning input up to the first character that is not white-space (which remains unscanned), or until no more characters can be scanned.

manpage:
All other characters in the format string must have a matching character in the input string, except for whitespace, which
matches zero or more whitespace characters in the input string.

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120916/7535a9e1/attachment.asc>


More information about the ffmpeg-devel mailing list