From: VMware, Inc <> Date: Wed, 18 Sep 2013 03:12:08 +0000 (-0700) Subject: Internal branch sync. Included in this change: X-Git-Tag: 2013.09.16-1328054~122 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=737ced1b4fab413f56ac4aa1532191de87a552d8;p=thirdparty%2Fopen-vm-tools.git Internal branch sync. Included in this change: . Properly handle timezone in TimeUtil_SecondsSinceEpoch() . changes in shared code that don't affect open-vm-tools functionality Signed-off-by: Dmitry Torokhov --- diff --git a/open-vm-tools/lib/include/vm_product_versions.h b/open-vm-tools/lib/include/vm_product_versions.h index 19be23944..e0124b732 100644 --- a/open-vm-tools/lib/include/vm_product_versions.h +++ b/open-vm-tools/lib/include/vm_product_versions.h @@ -362,7 +362,7 @@ # 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 diff --git a/open-vm-tools/lib/misc/timeutil.c b/open-vm-tools/lib/misc/timeutil.c index bbd892c5c..23d7f0fe9 100644 --- a/open-vm-tools/lib/misc/timeutil.c +++ b/open-vm-tools/lib/misc/timeutil.c @@ -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 }