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