-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDate.pde
73 lines (65 loc) · 1.22 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
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%8;
hour=h%13;
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 () {
++hour;
if (hour>=13)
{
hour%=13;
hour++;
if (before_noon)
before_noon=false;
else {
before_noon=true;
today+=1;
if (today>6)
today%=7;
}
}
}
void addMinute () {
++minute;
if (minute>=60)
{
minute%=60;
addHour();
}
}
String toString() {
String date= days[today];
if (hour<10)
date+=" 0"+hour;
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;
}
}