-
Notifications
You must be signed in to change notification settings - Fork 0
/
time.c
39 lines (27 loc) · 818 Bytes
/
time.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
#include "wax.h"
Time convertToMins(int sec) {
int h, m, s;
char timestring[20];
Time convertedTime;
convertedTime.hours = h = (sec / 3600);
convertedTime.min = m = (sec - (3600 * h)) / 60;
convertedTime.sec = s = (sec - (3600 * h) - (m * 60));
if (h > 0) {
sprintf(timestring, "%d:%s%d:%s%d", h, m < 10 ? "0" : "", m,
s < 10 ? "0" : "", s);
} else {
sprintf(timestring, "%s%d:%s%d", m < 10 ? "0" : "", m, s < 10 ? "0" : "",
s);
}
strcpy(convertedTime.timestring, timestring);
return convertedTime;
}
void printTime(WINDOW *window, int rows, int cols, Time time, chtype color) {
if (NULL == window) {
window = stdscr;
}
wattron(window, color);
mvwprintw(window, rows, cols, "%s", time.timestring);
wattroff(window, color);
refresh();
}