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