wtv: Avoid needlessly calling gmtime twice with the same argument

Signed-off-by: Martin Storsjö <martin@martin.st>
lavf: Check the return value of strftime

If the buffer provided to strftime is too small, the buffer contents
are indeterminate - it does not guarantee actually null terminating
the buffer.

Signed-off-by: Martin Storsjö <martin@martin.st>
lavu: Provide fallbacks for gmtime_r and localtime_r

This allows writing most code as if they always are is available.

These are ok to use from other libraries even though it's not a
public header, since they only provide an inline declaration, and
doesn't add an actual dependency on lavu internals. (This can be
considered more a build system compatibility fallback than a
libavutil feature.)

Signed-off-by: Martin Storsjö <martin@martin.st>
Use gmtime_r instead of gmtime and localtime_r instead of localtime

gmtime isn't thread safe in general. In msvcrt (which lacks gmtime_r),
the buffer used by gmtime is thread specific though.

One call to localtime is left in avconv_opt.c, where thread safety
shouldn't matter (instead of making avconv depend on the libavutil
internal header).

Signed-off-by: Martin Storsjö <martin@martin.st>
drawtext: Remove the ifdef for localtime_r

If it isn't available in the system, we've got a fallback to
the normal localtime function, so normal code can assume it is
available as long as time_internal.h is included.

Signed-off-by: Martin Storsjö <martin@martin.st>
lavf: Implement ff_brktimegm using gmtime_r

While a standalone implementation is nice, we already depend on
gmtime and gmtime_r in a number of places.

Signed-off-by: Martin Storsjö <martin@martin.st>