]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
Avoid glibc-specific time extensions. 580/head
authorPhilip Lorenz <philip@bithub.de>
Sat, 2 Jan 2016 11:03:55 +0000 (12:03 +0100)
committerÉrico Rolim <erico.erc@gmail.com>
Sat, 10 Oct 2020 03:32:27 +0000 (00:32 -0300)
* Use mktime instead of timelocal
* Replace glibc specific time format string
* Inline private __isleap() macro from glibc

client/utils/equal-date.cc
snapper/AppUtil.cc

index b367c64b6ae31d183fcb8a493607b2fd0357a0de..dbea15d54c18b5087f74092c65deb02a92ec2159 100644 (file)
@@ -24,6 +24,8 @@
 
 #include "equal-date.h"
 
+#define isleapyear(year) \
+    ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
 
 int
 yday_of_weeks_monday(const struct tm& tmp)
@@ -35,7 +37,7 @@ yday_of_weeks_monday(const struct tm& tmp)
 int
 days_in_year(const struct tm& tmp)
 {
-    return __isleap(tmp.tm_year) ? 366 : 365;
+    return isleapyear(tmp.tm_year) ? 366 : 365;
 }
 
 
index 8e80e7191ac929a099516e50f231c72abc032c62..54a4403479956e281d1f7da72340e1b876321d4e 100644 (file)
@@ -285,10 +285,10 @@ namespace snapper
     {
        struct tm s;
        memset(&s, 0, sizeof(s));
-       const char* p = strptime(str.c_str(), "%F %T", &s);
+       const char* p = strptime(str.c_str(), "%Y-%m-%d %T", &s);
        if (!p || *p != '\0')
            return (time_t)(-1);
-       return utc ? timegm(&s) : timelocal(&s);
+       return utc ? timegm(&s) : mktime(&s);
     }