]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Changes to common source files not directly applicable to open-vm-tools.
authorJohn Wolfe <jwolfe@vmware.com>
Tue, 22 Sep 2020 21:54:05 +0000 (14:54 -0700)
committerJohn Wolfe <jwolfe@vmware.com>
Tue, 22 Sep 2020 21:54:05 +0000 (14:54 -0700)
open-vm-tools/lib/include/timeutil.h
open-vm-tools/lib/misc/timeutil.c

index 971d40fa3618d90911983128e0b3c57c26d5f896..a927b3f4e9be5b4899509698073ed8646724be94 100644 (file)
@@ -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
index 06b61e47f5a901ed21c134d7479ed78bd4df1ecf..0793126f1cf1834b9aad24b54457942dec120d31 100644 (file)
@@ -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
 /*
  *----------------------------------------------------------------------