mirror of
https://github.com/janbodnar/Windows-API-examples.git
synced 2024-11-24 11:25:30 +00:00
Create localtime_to_universaltime.c
This commit is contained in:
parent
200f998402
commit
e965a872b6
32
datetime/localtime_to_universaltime.c
Normal file
32
datetime/localtime_to_universaltime.c
Normal file
@ -0,0 +1,32 @@
|
||||
#include <windows.h>
|
||||
#include <wchar.h>
|
||||
|
||||
int wmain(void) {
|
||||
|
||||
SYSTEMTIME lt = {0};
|
||||
GetLocalTime(<);
|
||||
|
||||
TIME_ZONE_INFORMATION tzi = {0};
|
||||
GetTimeZoneInformation(&tzi);
|
||||
|
||||
SYSTEMTIME utm = {0};
|
||||
|
||||
int r = TzSpecificLocalTimeToSystemTime(&tzi, <, &utm);
|
||||
|
||||
if (r == 0) {
|
||||
|
||||
wprintf(L"Failed to convert local time to system time %d\n)",
|
||||
GetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
wprintf(L"Date: %d/%d/%d\n", lt.wMonth, lt.wDay, lt.wYear);
|
||||
|
||||
wprintf(L"The local time is: %02d:%02d:%02d\n",
|
||||
lt.wHour, lt.wMinute, lt.wSecond);
|
||||
|
||||
wprintf(L"The universal time is: %02d:%02d:%02d\n",
|
||||
utm.wHour, utm.wMinute, utm.wSecond);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user