Browse code

avutil: Add av_timegm as a public function

This is useful, since the normal timegm function isn't a standard
function (requiring _BSD_SOURCE or _SVID_SOURCE on glibc to
be visible, and not available on e.g. windows). The widely available
function mktime uses the local time zone, which requires ugly
workarounds to handle UTC time.

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

Martin Storsjö authored on 2011/11/08 06:20:31
Showing 4 changed files
... ...
@@ -13,6 +13,9 @@ libavutil:   2011-04-18
13 13
 
14 14
 API changes, most recent first:
15 15
 
16
+2011-11-xx - xxxxxxx - lavu 51.16.0
17
+  Add av_timegm()
18
+
16 19
 2011-11-06 - ba04ecf - lavu 51.14.0
17 20
   Add av_strcasecmp() and av_strncasecmp() to avstring.h.
18 21
 
... ...
@@ -40,7 +40,7 @@
40 40
 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
41 41
 
42 42
 #define LIBAVUTIL_VERSION_MAJOR 51
43
-#define LIBAVUTIL_VERSION_MINOR 15
43
+#define LIBAVUTIL_VERSION_MINOR 16
44 44
 #define LIBAVUTIL_VERSION_MICRO  0
45 45
 
46 46
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
... ...
@@ -461,7 +461,7 @@ static const char *small_strptime(const char *p, const char *fmt, struct tm *dt)
461 461
     }
462 462
 }
463 463
 
464
-static time_t mktimegm(struct tm *tm)
464
+time_t av_timegm(struct tm *tm)
465 465
 {
466 466
     time_t t;
467 467
 
... ...
@@ -582,7 +582,7 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration)
582 582
     } else {
583 583
         dt.tm_isdst = -1;       /* unknown */
584 584
         if (is_utc) {
585
-            t = mktimegm(&dt);
585
+            t = av_timegm(&dt);
586 586
         } else {
587 587
             t = mktime(&dt);
588 588
         }
... ...
@@ -19,6 +19,8 @@
19 19
 #ifndef AVUTIL_PARSEUTILS_H
20 20
 #define AVUTIL_PARSEUTILS_H
21 21
 
22
+#include <time.h>
23
+
22 24
 #include "rational.h"
23 25
 
24 26
 /**
... ...
@@ -114,4 +116,9 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration);
114 114
  */
115 115
 int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
116 116
 
117
+/**
118
+ * Convert the decomposed UTC time in tm to a time_t value.
119
+ */
120
+time_t av_timegm(struct tm *tm);
121
+
117 122
 #endif /* AVUTIL_PARSEUTILS_H */