From: John Wolfe Date: Tue, 22 Sep 2020 21:54:05 +0000 (-0700) Subject: Changes to common source files not directly applicable to open-vm-tools. X-Git-Tag: stable-11.3.0~327 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49c898507badc4d19e17a5e3230116505aa58f93;p=thirdparty%2Fopen-vm-tools.git Changes to common source files not directly applicable to open-vm-tools. --- diff --git a/open-vm-tools/lib/include/timeutil.h b/open-vm-tools/lib/include/timeutil.h index 971d40fa3..a927b3f4e 100644 --- a/open-vm-tools/lib/include/timeutil.h +++ b/open-vm-tools/lib/include/timeutil.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2017 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2017,2020 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 @@ -130,6 +130,8 @@ int TimeUtil_NtTimeToUnixTime(struct timespec *unixTime, // OUT VmTimeType TimeUtil_UnixTimeToNtTime(struct timespec unixTime); // IN +Bool TimeUtil_IsValidDate(TimeUtil_Date const *d); // IN + #ifdef _WIN32 Bool TimeUtil_UTCTimeToSystemTime(const __time64_t utcTime, // IN diff --git a/open-vm-tools/lib/misc/timeutil.c b/open-vm-tools/lib/misc/timeutil.c index 06b61e47f..0793126f1 100644 --- a/open-vm-tools/lib/misc/timeutil.c +++ b/open-vm-tools/lib/misc/timeutil.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2019 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2020 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 @@ -956,6 +956,35 @@ TimeUtil_UnixTimeToNtTime(struct timespec unixTime) // IN: Time in Unix format unixTime.tv_nsec / 100 + UNIX_EPOCH; } + +/* + *----------------------------------------------------------------------------- + * + * TimeUtil_IsValidDate -- + * + * Checks out if the given time and date are valid. This function assumes + * that any valid minute might contain a leap second. + * + * Results: + * TRUE if the time and date are valid, FALSE otherwise. + * + * Side effects: + * None + * + *----------------------------------------------------------------------------- + */ + +Bool +TimeUtil_IsValidDate(TimeUtil_Date const *d) // IN +{ + if (!TimeUtilIsValidDate(d->year, d->month, d->day)) { + return FALSE; + } + + return d->hour < 24 && d->minute < 60 && d->second < 61; +} + + #ifdef _WIN32 /* *----------------------------------------------------------------------