-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdate.py
33 lines (25 loc) · 921 Bytes
/
date.py
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
daysPerMonth = {1:31,2:29,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}
class date:
def __init__(self, dateStr):
self.month = int(dateStr.split('/')[0])
self.day = int(dateStr.split('/')[1])
def next(self):
self.day += 1
if self.day > daysPerMonth[self.month]:
self.day = 1
self.month += 1
def back(self):
self.day -= 1
if self.day <= 0:
self.month -= 1
self.day = daysPerMonth[self.month]
def toString(self) -> str:
return self.toShortString() + "/2016"
def toShortString(self) -> str:
return str(self.month) + "/" + str(self.day)
def toDirString(self) -> str:
return self.toString().replace('/','.')
def equals(self, other) -> bool:
return self.day == other.day and self.month == other.month
def __lt__(self, other) -> bool:
return