]>
git.proxmox.com Git - mirror_edk2.git/blob - EmbeddedPkg/Include/Library/TimeBaseLib.h
a9f3c6588b75fbd576fe08a86914a52a1bc59678
3 * Copyright (c) 2016, Hisilicon Limited. All rights reserved.
4 * Copyright (c) 2016-2019, Linaro Limited. All rights reserved.
5 * Copyright (c) 2021, Ampere Computing LLC. All rights reserved.
7 * SPDX-License-Identifier: BSD-2-Clause-Patent
11 #ifndef _TIME_BASE_LIB_H_
12 #define _TIME_BASE_LIB_H_
14 #include <Uefi/UefiBaseType.h>
17 // Convenience macros to obtain a build date
19 // These macros should work for any compiler that follows ISO/IEC 9899,
20 // in which case __DATE__ is defined as a "Mmm dd yyyy" 11 chars string,
21 // but add an explicit filter for compilers that have been validated.
23 #if (defined(__GNUC__) || defined(_MSC_VER) || defined(__clang__))
24 #define TIME_BUILD_YEAR (__DATE__[7] == '?' ? 1900 \
25 : (((__DATE__[7] - '0') * 1000 ) \
26 + (__DATE__[8] - '0') * 100 \
27 + (__DATE__[9] - '0') * 10 \
28 + __DATE__[10] - '0'))
29 #define TIME_BUILD_MONTH ( __DATE__ [2] == '?' ? 1 \
30 : __DATE__ [2] == 'n' ? ( \
31 __DATE__ [1] == 'a' ? 1 : 6) \
32 : __DATE__ [2] == 'b' ? 2 \
33 : __DATE__ [2] == 'r' ? ( \
34 __DATE__ [0] == 'M' ? 3 : 4) \
35 : __DATE__ [2] == 'y' ? 5 \
36 : __DATE__ [2] == 'l' ? 7 \
37 : __DATE__ [2] == 'g' ? 8 \
38 : __DATE__ [2] == 'p' ? 9 \
39 : __DATE__ [2] == 't' ? 10 \
40 : __DATE__ [2] == 'v' ? 11 \
42 #define TIME_BUILD_DAY ( __DATE__[4] == '?' ? 1 \
43 : ((__DATE__[4] == ' ' ? 0 : \
44 ((__DATE__[4] - '0') * 10)) \
48 // Define EPOCH (1970-JANUARY-01) in the Julian Date representation
49 #define EPOCH_JULIAN_DATE 2440588
52 #define SEC_PER_MIN ((UINTN) 60)
53 #define SEC_PER_HOUR ((UINTN) 3600)
54 #define SEC_PER_DAY ((UINTN) 86400)
57 Check if it is a leap year.
59 @param Time The UEFI time to be checked.
61 @retval TRUE It is a leap year.
62 @retval FALSE It is NOT a leap year.
72 Check if the day in the UEFI time is valid.
74 @param Time The UEFI time to be checked.
77 @retval FALSE Invalid.
87 Check if the UEFI time is valid.
89 @param Time The UEFI time to be checked.
92 @retval FALSE Invalid.
102 Converts Epoch seconds (elapsed since 1970 JANUARY 01, 00:00:00 UTC) to EFI_TIME.
104 @param EpochSeconds Epoch seconds.
105 @param Time The time converted to UEFI format.
111 IN UINTN EpochSeconds
,
116 Converts EFI_TIME to Epoch seconds (elapsed since 1970 JANUARY 01, 00:00:00 UTC).
118 @param Time The UEFI time to be converted.
120 @return Number of seconds.
130 Get the day of the week from the UEFI time.
132 @param Time The UEFI time to be calculated.
134 @return The day of the week: Sunday=0, Monday=1, ... Saturday=6