Repository navigation
Expand file tree
/
Copy pathcalendar.c
More file actions
69 lines (62 loc) · 1.71 KB
/
Copy pathcalendar.c
File metadata and controls
69 lines (62 loc) · 1.71 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
#include "calendar.h"
#include "tyac.h"
#include <conio.h>
#include <stdio.h>
#define INDENT " "
void Calc_Calendar(int calendar[][7], int *daysinmonth, int day, int month, int year) {
int col, row, x;
switch (month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
*daysinmonth = 31;
break;
case 4:
case 6:
case 9:
case 11:
*daysinmonth = 30;
break;
case 2:
*daysinmonth = 28;
if (Is_LeapYear(year))
*daysinmonth = 29;
break;
}
/* initialise calendar array */
for (row = 0; row < 6; row++)
for (col = 0; col < 7; col++)
calendar[row][col] = 0;
/* load days of month into calendar array */
for (row = 0, x = 1; x <= *daysinmonth; row++)
for (col = day; x <= *daysinmonth; col++)
calendar[row][col] = x++;
}
void Display_Calendar(int calendar[][7], char *monthlist[12], int day, int month, int year) {
int row, col;
textcolor(LIGHTCYAN);
textbackground(BLUE);
cprintf("%s\n%39d \r%s%s\r\n", INDENT, year, INDENT, monthlist[month - 1]); /* print month and year of calendar */
cprintf("%sSun Mon Tue Wed Thu Fri Sat\r\n%s ", INDENT, INDENT);
write_string("+Month+ <Page Dn>", CYAN, BLUE, 0, 63);
write_string("-Month- <Page Up>", CYAN, BLUE, 0, 0);
textcolor(WHITE);
textbackground(BLUE);
for (row = 0; row < 6; row++, cprintf("\r\n%s ", INDENT))
for (col = 0; col < 7; col++) {
if (calendar[row][col] == day) {
textcolor(YELLOW + BLINK);
textbackground(BLUE);
cprintf("%-6d", calendar[row][col]);
textcolor(WHITE);
textbackground(BLUE);
} else if (calendar[row][col])
cprintf("%-6d", calendar[row][col]);
else
cprintf(" ");
}
}