+#if HAVE_TIMEGM
+ time_t t = timegm(&tm);
+ if (t == ((time_t)-1)) {
+ char errbuf[1024];
+ ERROR("bind plugin: timegm() failed: %s",
+ sstrerror(errno, errbuf, sizeof(errbuf)));
+ return -1;
+ }
+ *ret_value = t;
+#else
+ time_t t = mktime(&tm);
+ if (t == ((time_t)-1)) {
+ char errbuf[1024];
+ ERROR("bind plugin: mktime() failed: %s",
+ sstrerror(errno, errbuf, sizeof(errbuf)));
+ return -1;
+ }
+ /* mktime assumes that tm is local time. Luckily, it also sets timezone to
+ * the offset used for the conversion, and we undo the conversion to convert
+ * back to UTC. */
+ *ret_value = t - timezone;
+#endif