Repository navigation
Expand file tree
/
Copy pathdays_to_xmas.c
More file actions
94 lines (65 loc) · 1.88 KB
/
Copy pathdays_to_xmas.c
File metadata and controls
94 lines (65 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <windows.h>
#include <wchar.h>
int wmain(void) {
FILETIME ft1 = {0};
FILETIME ft2 = {0};
SYSTEMTIME st = {0};
LARGE_INTEGER li1 = {0};
LARGE_INTEGER li2 = {0};
st.wYear = 2016;
st.wMonth = 12;
st.wDay = 25;
int r = SystemTimeToFileTime(&st, &ft1);
if (r == 0) {
wprintf(L"Failed to convert system time to file time\n (%d)",
GetLastError());
return 1;
}
GetSystemTimeAsFileTime(&ft2);
li1.LowPart = ft1.dwLowDateTime;
li1.HighPart = ft1.dwHighDateTime;
li2.LowPart = ft2.dwLowDateTime;
li2.HighPart = ft2.dwHighDateTime;
long long int dif = li1.QuadPart - li2.QuadPart;
int days2xmas = dif / 10000000L / 60 / 60 / 24;
if (days2xmas == 1) {
wprintf(L"There is one day until Christmas\n", days2xmas);
} else if (days2xmas == 0) {
wprintf(L"Today is Chritmas\n");
} else {
wprintf(L"There are %ld days until Christmas\n", days2xmas);
}
return 0;
}
/* int wmain()
{
FILETIME ft1 = {0};
FILETIME ft2 = {0};
SYSTEMTIME st = {0};
LARGE_INTEGER li1 = {0};
LARGE_INTEGER li2 = {0};
st.wYear = 2019;
st.wMonth = 9;
st.wDay = 1;
int r = SystemTimeToFileTime(&st, &ft1);
if(0 == r)
{
wprintf(L"Failed to convert system time to file file\n (%d)", GetLastError());
return 1;
}
GetSystemTimeAsFileTime(&ft2);
li1.LowPart = ft1.dwLowDateTime;
li1.HighPart = ft1.dwHighDateTime;
li2.LowPart = ft2.dwLowDateTime;
li2.HighPart = ft2.dwHighDateTime;
long long int dif = li1.QuadPart - li2.QuadPart;
int days2xmas = dif / 10000000L / 60 / 60 / 24;
if (days2xmas == 1) {
wprintf(L"There is one day until Christmas\n", days2xmas);
} else if (days2xmas == 0) {
wprintf(L"Today is Chritmas\n");
} else {
wprintf(L"There are %d days until Christmas\n", days2xmas);
}
return 0;
} */