]> git.proxmox.com Git - mirror_edk2.git/blob - StdLib/LibC/Time/TimeEfi.c
Add Socket Libraries.
[mirror_edk2.git] / StdLib / LibC / Time / TimeEfi.c
1 /** @file
2 Transformations between the EFI_TIME structure and struct tm or time_t.
3
4 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14 #include <Uefi.h>
15
16 #include <LibConfig.h>
17
18 #include <time.h>
19 #include "tzfile.h"
20 #include <MainData.h>
21
22 /* Convert an EFI_TIME structure into a C Standard tm structure. */
23 void
24 Efi2Tm( EFI_TIME *ET, struct tm *BT)
25 {
26 // Convert EFI time to broken-down time.
27 BT->tm_year = ET->Year - TM_YEAR_BASE;
28 BT->tm_mon = ET->Month - 1; // BD time is zero based, EFI is 1 based
29 BT->tm_mday = ET->Day;
30 BT->tm_hour = ET->Hour;
31 BT->tm_min = ET->Minute;
32 BT->tm_sec = ET->Second;
33 BT->tm_isdst = -1;
34 BT->tm_zoneoff = ET->TimeZone;
35 BT->tm_daylight = ET->Daylight;
36 BT->tm_Nano = ET->Nanosecond;
37 }
38
39 /* Convert an EFI_TIME structure into a time_t value. */
40 time_t
41 Efi2Time( EFI_TIME *EfiBDtime)
42 {
43 Efi2Tm( EfiBDtime, &gMD->BDTime);
44
45 return mktime( &gMD->BDTime);
46 }