TimeBaseLib.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /** @file
  2. *
  3. * Copyright (c) 2016, Hisilicon Limited. All rights reserved.
  4. * Copyright (c) 2016, Linaro Limited. All rights reserved.
  5. *
  6. * SPDX-License-Identifier: BSD-2-Clause-Patent
  7. *
  8. **/
  9. #ifndef _TIME_BASE_LIB_H_
  10. #define _TIME_BASE_LIB_H_
  11. #include <Uefi/UefiBaseType.h>
  12. // Define EPOCH (1970-JANUARY-01) in the Julian Date representation
  13. #define EPOCH_JULIAN_DATE 2440588
  14. // Seconds per unit
  15. #define SEC_PER_MIN ((UINTN) 60)
  16. #define SEC_PER_HOUR ((UINTN) 3600)
  17. #define SEC_PER_DAY ((UINTN) 86400)
  18. #define SEC_PER_MONTH ((UINTN) 2,592,000)
  19. #define SEC_PER_YEAR ((UINTN) 31,536,000)
  20. BOOLEAN
  21. EFIAPI
  22. IsLeapYear (
  23. IN EFI_TIME *Time
  24. );
  25. BOOLEAN
  26. EFIAPI
  27. IsDayValid (
  28. IN EFI_TIME *Time
  29. );
  30. BOOLEAN
  31. EFIAPI
  32. IsTimeValid (
  33. IN EFI_TIME *Time
  34. );
  35. /**
  36. Converts Epoch seconds (elapsed since 1970 JANUARY 01, 00:00:00 UTC) to EFI_TIME
  37. **/
  38. VOID
  39. EFIAPI
  40. EpochToEfiTime (
  41. IN UINTN EpochSeconds,
  42. OUT EFI_TIME *Time
  43. );
  44. /**
  45. Converts EFI_TIME to Epoch seconds (elapsed since 1970 JANUARY 01, 00:00:00 UTC)
  46. **/
  47. UINTN
  48. EFIAPI
  49. EfiTimeToEpoch (
  50. IN EFI_TIME *Time
  51. );
  52. /**
  53. returns Day of the week [0-6] 0=Sunday
  54. **/
  55. UINTN
  56. EfiTimeToWday (
  57. IN EFI_TIME *Time
  58. );
  59. #endif