]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c
EmbeddedPkg/RealTimeClockRuntimeDxe: Use helper functions from TimeBaseLib
[mirror_edk2.git] / EmbeddedPkg / RealTimeClockRuntimeDxe / RealTimeClock.c
index 20f1fa640ecc54a7c2974d76d434dbb14b7379c5..e59036badc91fb90024edb763f16f84bf443e04d 100644 (file)
@@ -3,6 +3,7 @@
 \r
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
   Copyright (c) 2017, Linaro, Ltd. All rights reserved.<BR>\r
+  Copyright (c) 2021, Ampere Computing LLC. All rights reserved.<BR>\r
 \r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -11,6 +12,7 @@
 #include <PiDxe.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/RealTimeClockLib.h>\r
+#include <Library/TimeBaseLib.h>\r
 #include <Library/UefiLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/UefiRuntimeLib.h>\r
@@ -31,92 +33,6 @@ typedef struct {
 STATIC CONST CHAR16 mTimeSettingsVariableName[] = L"RtcTimeSettings";\r
 STATIC NON_VOLATILE_TIME_SETTINGS mTimeSettings;\r
 \r
-STATIC\r
-BOOLEAN\r
-IsValidTimeZone (\r
-  IN  INT16  TimeZone\r
-  )\r
-{\r
-  return TimeZone == EFI_UNSPECIFIED_TIMEZONE ||\r
-         (TimeZone >= -1440 && TimeZone <= 1440);\r
-}\r
-\r
-STATIC\r
-BOOLEAN\r
-IsValidDaylight (\r
-  IN  INT8  Daylight\r
-  )\r
-{\r
-  return Daylight == 0 ||\r
-         Daylight == EFI_TIME_ADJUST_DAYLIGHT ||\r
-         Daylight == (EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT);\r
-}\r
-\r
-STATIC\r
-BOOLEAN\r
-EFIAPI\r
-IsLeapYear (\r
-  IN EFI_TIME   *Time\r
-  )\r
-{\r
-  if (Time->Year % 4 == 0) {\r
-    if (Time->Year % 100 == 0) {\r
-      if (Time->Year % 400 == 0) {\r
-        return TRUE;\r
-      } else {\r
-        return FALSE;\r
-      }\r
-    } else {\r
-      return TRUE;\r
-    }\r
-  } else {\r
-    return FALSE;\r
-  }\r
-}\r
-\r
-STATIC CONST INTN mDayOfMonth[12] = {\r
-  31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31\r
-};\r
-\r
-STATIC\r
-BOOLEAN\r
-EFIAPI\r
-IsDayValid (\r
-  IN  EFI_TIME  *Time\r
-  )\r
-{\r
-  if (Time->Day < 1 ||\r
-      Time->Day > mDayOfMonth[Time->Month - 1] ||\r
-      (Time->Month == 2 && !IsLeapYear (Time) && Time->Day > 28)) {\r
-    return FALSE;\r
-  }\r
-  return TRUE;\r
-}\r
-\r
-STATIC\r
-BOOLEAN\r
-EFIAPI\r
-IsTimeValid(\r
-  IN EFI_TIME *Time\r
-  )\r
-{\r
-  // Check the input parameters are within the range specified by UEFI\r
-  if (Time->Year   < 1900               ||\r
-      Time->Year   > 9999               ||\r
-      Time->Month  < 1                  ||\r
-      Time->Month  > 12                 ||\r
-      !IsDayValid (Time)                ||\r
-      Time->Hour   > 23                 ||\r
-      Time->Minute > 59                 ||\r
-      Time->Second > 59                 ||\r
-      Time->Nanosecond > 999999999      ||\r
-      !IsValidTimeZone (Time->TimeZone) ||\r
-      !IsValidDaylight (Time->Daylight)) {\r
-    return FALSE;\r
-  }\r
-  return TRUE;\r
-}\r
-\r
 /**\r
   Returns the current time and date information, and the time-keeping capabilities\r
   of the hardware platform.\r