-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock.c
52 lines (52 loc) · 1.43 KB
/
clock.c
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
#include <stdio.h>
#include <time.h>
#include <windows.h>
#define BUF_LEN 256
#define WINVER 0x0500
int main()
{
HWND wh = GetConsoleWindow();
MoveWindow(wh, 500, 200, 230, 120, TRUE);
while(1)
{
char buf[BUF_LEN] = {0};
system("color 0A");
system("cls");
time_t s;
struct tm* current_time;
time_t rawtime = time(NULL);
struct tm *ptm = localtime(&rawtime);
s = time(NULL);
current_time = localtime(&s);
if(current_time->tm_hour >12)
{
printf("\n\t");
printf("%02d:%02d:%02d PM",
current_time->tm_hour-12,
current_time->tm_min,
current_time->tm_sec);
printf("\n\t");
strftime(buf, BUF_LEN, "(%A)", ptm);
puts(buf);
printf("\t");
strftime(buf, BUF_LEN, "%d.%m.%Y", ptm);
puts(buf);
}
else
{
printf("\n\t");
printf("%02d:%02d:%02d AM",
current_time->tm_hour,
current_time->tm_min,
current_time->tm_sec);
printf("\n\t");
strftime(buf, BUF_LEN, "(%A)", ptm);
puts(buf);
printf("\t");
strftime(buf, BUF_LEN, "%d.%m.%Y", ptm);
puts(buf);
}
sleep(1);
}
return 0;
}