]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Internal branch sync. Included in this change:
authorVMware, Inc <>
Wed, 18 Sep 2013 03:12:08 +0000 (20:12 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sun, 22 Sep 2013 01:27:21 +0000 (18:27 -0700)
. Properly handle timezone in TimeUtil_SecondsSinceEpoch()
. changes in shared code that don't affect open-vm-tools functionality

Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
open-vm-tools/lib/include/vm_product_versions.h
open-vm-tools/lib/misc/timeutil.c

index 19be23944928967f75444bf9db08148b18e727dd..e0124b732f269344d6fa67ba2adadc231498d1bb 100644 (file)
 #  define PRODUCT_VERSION_STRING_FOR_LICENSE PRODUCT_LICENSE_VERSION
 #endif
 
-#define PRODUCT_PLAYER_VERSION_STRING_FOR_LICENSE "5.0"
+#define PRODUCT_PLAYER_VERSION_STRING_FOR_LICENSE "6.0"
 
 /*
  * This is for ACE Management Server
index bbd892c5c60e7e35cac6cfbb6f5956a2e870de25..23d7f0fe99556d2f29cfddcf7c8b53ebf6d0bc83 100644 (file)
@@ -1570,8 +1570,6 @@ static int Win32TimeUtilLookupZoneIndex(const char* targetName)
 time_t
 TimeUtil_SecondsSinceEpoch(TimeUtil_Date *d) // IN
 {
-   const int DAY_IN_SECONDS = 60*60*24;
-   struct tm tmval1970 = {0};
    struct tm tmval = {0};
 
    /*
@@ -1582,15 +1580,6 @@ TimeUtil_SecondsSinceEpoch(TimeUtil_Date *d) // IN
       return -1;
    }
 
-   /*
-    * Get the localtime for Jan 2nd 1970. We need to get the 2nd because
-    * if we are in a timezone that is + UTC then mktime will return -1
-    * for Jan 1st.
-    */
-   tmval1970.tm_year= 1970 - 1900;
-   tmval1970.tm_mon = 0;
-   tmval1970.tm_mday = 2;
-
    tmval.tm_year = d->year - 1900;
    tmval.tm_mon = d->month - 1;
    tmval.tm_mday = d->day;
@@ -1598,8 +1587,20 @@ TimeUtil_SecondsSinceEpoch(TimeUtil_Date *d) // IN
    tmval.tm_min = d->minute;
    tmval.tm_sec = d->second;
 
+#if defined(_WIN32)
    /*
-    * Add back in the day.
-    */
-   return mktime(&tmval) - mktime(&tmval1970) + DAY_IN_SECONDS;
+   * Workaround since Win32 doesn't have timegm(). Use the win32
+   * _get_timezone to adjust to UTC.
+   */
+   {
+      int utcSeconds = 0;
+      _get_timezone(&utcSeconds);
+      return mktime(&tmval) - utcSeconds;
+   }
+#elif (defined(__linux__) || defined(__APPLE__)) && !defined(__ANDROID__)
+   return timegm(&tmval);
+#else
+   NOT_IMPLEMENTED();
+   return -1;
+#endif
 }