]> git.proxmox.com Git - mirror_edk2.git/blob - StdLib/LibC/Time/TimeEfi.c
Standard Libraries for EDK II.
[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 EFIAPI
25 Efi2Tm( EFI_TIME *ET, struct tm *BT)
26 {
27 // Convert EFI time to broken-down time.
28 BT->tm_year = ET->Year - TM_YEAR_BASE;
29 BT->tm_mon = ET->Month - 1; // BD time is zero based, EFI is 1 based
30 BT->tm_mday = ET->Day;
31 BT->tm_hour = ET->Hour;
32 BT->tm_min = ET->Minute;
33 BT->tm_sec = ET->Second;
34 BT->tm_isdst = -1;
35 BT->tm_zoneoff = ET->TimeZone;
36 BT->tm_daylight = ET->Daylight;
37 BT->tm_Nano = ET->Nanosecond;
38 }
39
40 /* Convert an EFI_TIME structure into a time_t value. */
41 time_t
42 EFIAPI
43 Efi2Time( EFI_TIME *EfiBDtime)
44 {
45 Efi2Tm( EfiBDtime, &gMD->BDTime);
46
47 return mktime( &gMD->BDTime);
48 }