/*********************************************************
- * Copyright (C) 1998-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2017 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
/*
* NT time of the Unix epoch:
- * midnight January 1, 1970 UTC
+ * Midnight January 1, 1970 UTC
*/
#define UNIX_EPOCH ((((uint64)369 * 365) + 89) * 24 * 3600 * 10000000)
*/
time_t
-TimeUtil_MakeTime(const TimeUtil_Date *d) // IN
+TimeUtil_MakeTime(const TimeUtil_Date *d) // IN:
{
struct tm t;
*/
Bool
-TimeUtil_StringToDate(TimeUtil_Date *d, // IN/OUT
- char const *date) // IN
+TimeUtil_StringToDate(TimeUtil_Date *d, // IN/OUT:
+ char const *date) // IN:
{
/*
* Reduce the string to a known and handled format: YYYYMMDD.
return FALSE;
}
- Str_Strcpy(temp, date, sizeof(temp));
+ Str_Strcpy(temp, date, sizeof temp);
temp[4] = date[5];
temp[5] = date[6];
temp[6] = date[8];
*/
int
-TimeUtil_DeltaDays(TimeUtil_Date const *left, // IN
- TimeUtil_Date const *right) // IN
+TimeUtil_DeltaDays(TimeUtil_Date const *left, // IN:
+ TimeUtil_Date const *right) // IN:
{
TimeUtil_Date temp1;
TimeUtil_Date temp2;
*/
Bool
-TimeUtil_DaysSubtract(TimeUtil_Date *d, // IN/OUT
- unsigned int nr) // IN
+TimeUtil_DaysSubtract(TimeUtil_Date *d, // IN/OUT:
+ unsigned int nr) // IN:
{
TimeUtil_Date temp;
int subYear = 0;
*/
void
-TimeUtil_DaysAdd(TimeUtil_Date *d, // IN/OUT
- unsigned int nr) // IN
+TimeUtil_DaysAdd(TimeUtil_Date *d, // IN/OUT:
+ unsigned int nr) // IN:
{
const unsigned int *monthDays;
unsigned int i;
*/
void
-TimeUtil_PopulateWithCurrent(Bool local, // IN
- TimeUtil_Date *d) // OUT
+TimeUtil_PopulateWithCurrent(Bool local, // IN:
+ TimeUtil_Date *d) // OUT:
{
#ifdef _WIN32
SYSTEMTIME currentTime;
*/
void
-TimeUtil_GetTimeOfDay(TimeUtil_TimeOfDay *timeofday)
+TimeUtil_GetTimeOfDay(TimeUtil_TimeOfDay *timeofday) // OUT:
{
#ifdef _WIN32
// convert into microseconds (since the return is in 100 nseconds).
tmptime /= 10;
// Get the seconds and microseconds in the timeofday
- timeofday->seconds = (unsigned long)(tmptime / 1000000UL);
- timeofday->useconds = (unsigned long)(tmptime % 1000000UL);
-
+ timeofday->seconds = (unsigned long) (tmptime / 1000000UL);
+ timeofday->useconds = (unsigned long) (tmptime % 1000000UL);
#undef DELTA_EPOCH_IN_MICROSECS
#else
*/
unsigned int
-TimeUtil_DaysLeft(TimeUtil_Date const *d) // IN
+TimeUtil_DaysLeft(TimeUtil_Date const *d) // IN:
{
TimeUtil_Date c;
unsigned int i;
*/
Bool
-TimeUtil_ExpirationLowerThan(TimeUtil_Expiration const *left, // IN
- TimeUtil_Expiration const *right) // IN
+TimeUtil_ExpirationLowerThan(TimeUtil_Expiration const *left, // IN:
+ TimeUtil_Expiration const *right) // IN:
{
if (left->expires == FALSE) {
return FALSE;
*/
Bool
-TimeUtil_DateLowerThan(TimeUtil_Date const *left, // IN
- TimeUtil_Date const *right) // IN
+TimeUtil_DateLowerThan(TimeUtil_Date const *left, // IN:
+ TimeUtil_Date const *right) // IN:
{
ASSERT(left);
ASSERT(right);
*/
void
-TimeUtil_ProductExpiration(TimeUtil_Expiration *e) // OUT
+TimeUtil_ProductExpiration(TimeUtil_Expiration *e) // OUT:
{
/*
e->daysLeft = TimeUtil_DaysLeft(&e->when);
#else
static char *hard_expire = "No Expire";
- (void)hard_expire;
+ (void) hard_expire;
ASSERT(e);
*/
char *
-TimeUtil_GetTimeFormat(int64 utcTime, // IN
- Bool showDate, // IN
- Bool showTime) // IN
+TimeUtil_GetTimeFormat(int64 utcTime, // IN:
+ Bool showDate, // IN:
+ Bool showTime) // IN:
{
#ifdef _WIN32
SYSTEMTIME systemTime = { 0 };
*/
int
-TimeUtil_NtTimeToUnixTime(struct timespec *unixTime, // OUT: Time in Unix format
- VmTimeType ntTime) // IN: Time in Windows NT format
+TimeUtil_NtTimeToUnixTime(struct timespec *unixTime, // OUT: Time in Unix format
+ VmTimeType ntTime) // IN: Time in Windows NT format
{
#ifndef VM_X86_64
ASSERT(unixTime);
*/
VmTimeType
-TimeUtil_UnixTimeToNtTime(struct timespec unixTime) // IN: Time in Unix format
+TimeUtil_UnixTimeToNtTime(struct timespec unixTime) // IN: Time in Unix format
{
return (VmTimeType)unixTime.tv_sec * 10000000 +
unixTime.tv_nsec / 100 + UNIX_EPOCH;
*/
Bool
-TimeUtil_UTCTimeToSystemTime(const __time64_t utcTime, // IN
- SYSTEMTIME *systemTime) // OUT
+TimeUtil_UTCTimeToSystemTime(const __time64_t utcTime, // IN:
+ SYSTEMTIME *systemTime) // OUT:
{
int atmYear;
int atmMonth;
* TimeUtil_GetLocalWindowsTimeZoneIndexAndName --
*
* Determines the name and index for the computer's current time zone. The
- * name is always the name of the time zone in standard time, even if Daylight
- * Saving is currently in effect. This name is not localized, and is
- * intended to be used when Easy Installing a Vista or later guest.
+ * name is always the name of the time zone in standard time, even if
+ * Daylight Saving is currently in effect. This name is not localized, and
+ * isintended to be used when Easy Installing a Vista or later guest.
*
* Results:
* The index of the computer's current time zone. The name of the time zone
*
*----------------------------------------------------------------------
*/
+
int
-TimeUtil_GetLocalWindowsTimeZoneIndexAndName(char **ptzName) // OUT: returning TZ Name
+TimeUtil_GetLocalWindowsTimeZoneIndexAndName(char **ptzName) // OUT: returning TZ Name
{
int utcStdOffMins = 0;
int winTimeZoneIndex = (-1);
(PFNGetTZInfo) GetProcAddress(GetModuleHandleW(L"kernel32"),
"GetDynamicTimeZoneInformation");
- if (pfnGetTZInfo == NULL || pfnGetTZInfo(&tzInfo) == TIME_ZONE_ID_INVALID) {
+ if (pfnGetTZInfo == NULL ||
+ pfnGetTZInfo(&tzInfo) == TIME_ZONE_ID_INVALID) {
return (-1);
}
*/
static void
-TimeUtilInit(TimeUtil_Date *d)
+TimeUtilInit(TimeUtil_Date *d) // OUT:
{
ASSERT(d);
*/
static Bool
-TimeUtilIsValidDate(unsigned int year, // IN
- unsigned int month, // IN
- unsigned int day) // IN
+TimeUtilIsValidDate(unsigned int year, // IN:
+ unsigned int month, // IN:
+ unsigned int day) // IN:
{
const unsigned int *monthDays;
*/
static unsigned int const *
-TimeUtilMonthDaysForYear(unsigned int year) // IN
+TimeUtilMonthDaysForYear(unsigned int year) // IN:
{
static const unsigned int leap[13] =
{ 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
*/
static Bool
-TimeUtilLoadDate(TimeUtil_Date *d, // IN/OUT
- const char *date) // IN
+TimeUtilLoadDate(TimeUtil_Date *d, // IN/OUT:
+ const char *date) // IN:
{
char temp[16] = { 0 };
int i = 0;
*
*----------------------------------------------------------------------
*/
+
static int
TimeUtilFindIndexAndName(int utcStdOffMins, // IN: offset (in minutes)
const char *englishTzName, // IN/OPT: The English TZ name
const char **ptzName) // OUT: returning TZ Name
{
static struct _tzinfo {
- int winTzIndex;
+ int winTzIndex;
const char *winTzName;
- int utcStdOffMins;
+ int utcStdOffMins;
} TABLE[] = {
/*
*ptzName = NULL;
/*
- * Search for the first time zone that has the passed-in offset. Then, if the
- * caller also passed a name, search the time zones with that offset for a
- * time zone with that name.
+ * Search for the first time zone that has the passed-in offset. Then, if
+ * the caller also passed a name, search the time zones with that offset for
+ * a time zone with that name.
*
* If the caller does not pass a name, this loop returns the first time zone
- * that it finds with the given offset. Because the UTC offset does not uniquely
- * identify a time zone, this function can return a time zone that is not what
- * the caller intended. For an example, see bug 1159642. Callers should pass
- * a time zone name whenever possible.
+ * that it finds with the given offset. Because the UTC offset does not
+ * uniquely identify a time zone, this function can return a time zone that
+ * is not what the caller intended. For an example, see bug 1159642.
+ * Callers should pass a time zone name whenever possible.
*/
+
for (look = 0; look < tableSize; look++) {
if (TABLE[look].utcStdOffMins == utcStdOffMins) {
/* We found a time zone with the right offset. */
*
* TimeUtil_SecondsSinceEpoch --
*
- * Converts a date into the the number of seconds since the unix epoch in UTC.
+ * Converts a date into the the number of seconds since the unix epoch in
+ * UTC.
*
* Parameters:
* date to be converted.
*
*----------------------------------------------------------------------
*/
+
time_t
-TimeUtil_SecondsSinceEpoch(TimeUtil_Date *d) // IN
+TimeUtil_SecondsSinceEpoch(TimeUtil_Date *d) // IN:
{
struct tm tmval = {0};
*/
{
int utcSeconds = 0;
+
_get_timezone(&utcSeconds);
+
return mktime(&tmval) - utcSeconds;
}
#elif (defined(__linux__) || defined(__APPLE__)) && !defined(__ANDROID__)