-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDate.pde
94 lines (88 loc) · 1.76 KB
/
Date.pde
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
class Date {
final String [] days = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
int today;
int hour;
int minute;
boolean before_noon;
Date (int d, int h, int m, boolean beforeNoon) {
today=d%7;
hour =h%12;
minute=m%60;
before_noon=beforeNoon;
}
Date (Date d) {
today=d.today;
hour=d.hour;
minute=d.minute;
before_noon=d.before_noon;
}
void addHour() {
if (hour==11&&before_noon==true) {
hour = 0;
before_noon=false;
} else if (hour==11&&today==6&&before_noon==false) {
hour =0;
today=0;
before_noon=true;
} else if (hour==11&&before_noon==false) {
hour=0;
today +=1;
before_noon=true;
} else {
hour+=1;
}
}
void addMinute() {
if (minute==59) {
minute=0;
addHour();
} else
{
minute+=1;
}
}
String displaydate() {
String date=days[today];
if (hour<10&&hour>0) {
date += " 0"+hour;
} else if (hour==0)
date+=" 12";
else
date +=" "+hour;
if (minute<10) {
date+=":0"+minute;
} else
date+=":"+minute;
if (before_noon) {
date +=" AM";
} else {
date +=" PM";
}
return date;
}
String toString() {
String date=days[today];
if (hour<10&&hour>0) {
date += " 0"+hour;
} else if (hour==0)
date+=" 12";
else
date +=" "+hour;
if (minute<10) {
date+=":0"+minute;
} else
date+=":"+minute;
if (before_noon) {
date +=" AM";
} else {
date +=" PM";
}
return date;
}
boolean equal(Date date) {
if (date.today==today&&date.hour==hour&&date.minute==minute&&date.before_noon==before_noon) {
return true;
}
return false;
}
}