5.2.7 GetTime()
This service is rarely used. Use it only when the current time and date are required, such as marking the time and date of a critical error.
Caution: This service is typically only accurate to about 1 second. As a
result, UEFI drivers should not use this service to poll or wait for an event
from a device. Instead, the Stall()
service should be used for short
delays. The CreateEvent()
, CreateEventEx()
, and SetTimer()
services
should be used for longer delays.
Example 69 and Example 70, following, are two examples of the GetTime()
service. The first retrieves the current time and date in an EFI_TIME
structure. The second retrieves both the current time and date in an EFI_TIME
structure and the capabilities of the realtime clock hardware in an
EFI_TIME_CAPABILITIES
structure.
Example 69-Get time and date
#include <Uefi.h>
#include <Library/UefiRuntimeServicesTableLib.h>
EFI_STATUS Status;
EFI_TIME Time;
Status = gRT->GetTime (&Time, NULL);
Example 70-Get real time clock capabilities
#include <Uefi.h>
#include <Library/UefiRuntimeServicesTableLib.h>
EFI_STATUS Status;
EFI_TIME Time;
EFI_TIME_CAPABILITIES Capabilities;
Status = gRT->GetTime (&Time, &Capabilities);