EmbeddedPkg: import EfiTimeBaseLib (as TimeBaseLib)
[mirror_edk2.git] / EmbeddedPkg / Include / Library / TimeBaseLib.h
CommitLineData
b4895995
LL
1/** @file\r
2*\r
3* Copyright (c) 2016, Hisilicon Limited. All rights reserved.\r
4* Copyright (c) 2016, Linaro Limited. All rights reserved.\r
5*\r
6* This program and the accompanying materials\r
7* are licensed and made available under the terms and conditions of the BSD License\r
8* which accompanies this distribution. The full text of the license may be found at\r
9* http://opensource.org/licenses/bsd-license.php\r
10*\r
11* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13*\r
14**/\r
15\r
16#ifndef _TIME_BASE_LIB_H_\r
17#define _TIME_BASE_LIB_H_\r
18\r
19#include <Uefi/UefiBaseType.h>\r
20\r
21// Define EPOCH (1970-JANUARY-01) in the Julian Date representation\r
22#define EPOCH_JULIAN_DATE 2440588\r
23\r
24// Seconds per unit\r
25#define SEC_PER_MIN ((UINTN) 60)\r
26#define SEC_PER_HOUR ((UINTN) 3600)\r
27#define SEC_PER_DAY ((UINTN) 86400)\r
28#define SEC_PER_MONTH ((UINTN) 2,592,000)\r
29#define SEC_PER_YEAR ((UINTN) 31,536,000)\r
30\r
31BOOLEAN\r
32EFIAPI\r
33IsLeapYear (\r
34 IN EFI_TIME *Time\r
35 );\r
36\r
37BOOLEAN\r
38EFIAPI\r
39IsDayValid (\r
40 IN EFI_TIME *Time\r
41 );\r
42\r
43BOOLEAN\r
44EFIAPI\r
45IsTimeValid (\r
46 IN EFI_TIME *Time\r
47 );\r
48\r
49/**\r
50 Converts Epoch seconds (elapsed since 1970 JANUARY 01, 00:00:00 UTC) to EFI_TIME\r
51 **/\r
52VOID\r
53EFIAPI\r
54EpochToEfiTime (\r
55 IN UINTN EpochSeconds,\r
56 OUT EFI_TIME *Time\r
57 );\r
58\r
59/**\r
60 Converts EFI_TIME to Epoch seconds (elapsed since 1970 JANUARY 01, 00:00:00 UTC)\r
61 **/\r
62UINTN\r
63EFIAPI\r
64EfiTimeToEpoch (\r
65 IN EFI_TIME *Time\r
66 );\r
67\r
68#endif\r