summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--configure.ac1
-rw-r--r--lib/util.cc21
2 files changed, 19 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 3194718..3484146 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,12 +7,13 @@ AC_PROG_INSTALL
7AC_PROG_CXX 7AC_PROG_CXX
8AC_PROG_CC 8AC_PROG_CC
9AC_PROG_LIBTOOL 9AC_PROG_LIBTOOL
10PKG_PROG_PKG_CONFIG 10PKG_PROG_PKG_CONFIG
11 11
12AC_HEADER_STDC 12AC_HEADER_STDC
13AC_CHECK_FUNCS([timegm])
13 14
14AC_PATH_PROG([XSLTPROC],[xsltproc],[true]) 15AC_PATH_PROG([XSLTPROC],[xsltproc],[true])
15 16
16AC_MSG_CHECKING([for source tree version]) 17AC_MSG_CHECKING([for source tree version])
17if headrev=$(cd $srcdir && git rev-parse --verify HEAD 2>/dev/null) ; then 18if headrev=$(cd $srcdir && git rev-parse --verify HEAD 2>/dev/null) ; then
18 PACKAGE_SRC_VERSION="$(cd $srcdir && git describe --tags $headrev)" 19 PACKAGE_SRC_VERSION="$(cd $srcdir && git describe --tags $headrev)"
diff --git a/lib/util.cc b/lib/util.cc
index d979502..a46ba2a 100644
--- a/lib/util.cc
+++ b/lib/util.cc
@@ -119,12 +119,27 @@ namespace opkele {
119 char rv[25]; 119 char rv[25];
120 if(!strftime(rv,sizeof(rv)-1,"%Y-%m-%dT%H:%M:%SZ",&tm_t)) 120 if(!strftime(rv,sizeof(rv)-1,"%Y-%m-%dT%H:%M:%SZ",&tm_t))
121 throw failed_conversion(OPKELE_CP_ "failed to strftime()"); 121 throw failed_conversion(OPKELE_CP_ "failed to strftime()");
122 return rv; 122 return rv;
123 } 123 }
124 124
125#ifndef HAVE_TIMEGM
126 static time_t timegm(struct tm *t) {
127 char *tz = getenv("TZ");
128 setenv("TZ","",1); tzset();
129 time_t rv = mktime(t);
130 if(tz)
131 setenv("TZ",tz,1);
132 else
133 unsetenv("TZ");
134 tzset();
135 return rv;
136 }
137 #define timegm opkele::util::timegm
138#endif /* HAVE_TIMEGM */
139
125 time_t w3c_to_time(const string& w) { 140 time_t w3c_to_time(const string& w) {
126 int fraction; 141 int fraction;
127 struct tm tm_t; 142 struct tm tm_t;
128 memset(&tm_t,0,sizeof(tm_t)); 143 memset(&tm_t,0,sizeof(tm_t));
129 if( ( 144 if( (
130 sscanf( 145 sscanf(
@@ -142,16 +157,16 @@ namespace opkele {
142 &fraction 157 &fraction
143 ) != 7 158 ) != 7
144 ) ) 159 ) )
145 throw failed_conversion(OPKELE_CP_ "failed to sscanf()"); 160 throw failed_conversion(OPKELE_CP_ "failed to sscanf()");
146 tm_t.tm_mon--; 161 tm_t.tm_mon--;
147 tm_t.tm_year-=1900; 162 tm_t.tm_year-=1900;
148 time_t rv = mktime(&tm_t); 163 time_t rv = timegm(&tm_t);
149 if(rv==(time_t)-1) 164 if(rv==(time_t)-1)
150 throw failed_conversion(OPKELE_CP_ "failed to mktime()"); 165 throw failed_conversion(OPKELE_CP_ "failed to gmtime()");
151 return rv-timezone; 166 return rv;
152 } 167 }
153 168
154 /* 169 /*
155 * 170 *
156 */ 171 */
157 172