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