-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdateExample.py
More file actions
40 lines (34 loc) · 802 Bytes
/
dateExample.py
File metadata and controls
40 lines (34 loc) · 802 Bytes
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
import math
class Date:
def __init__(self):
self.dd = 25
self.mm=11
self.yy=2019
def display(self):
print(self.dd,self.mm,self.yy)
def __add__(self,days):
#validate days
#inc = math.floor((days / 365))
#self.yy += math.floor(inc)
#self.dd = (days / 365) -
self.dd += days
while (self.dd > 28):
if self.dd > 31 and self.mm in (1,3,5,7,8,10,12):
self.dd -= 31
self.mm += 1
if self.mm == 13:
self.mm == 1
self.yy += 1
elif self.dd > 30 and self.mm in (4,6,9,11):
self.dd -= 30
self.mm += 1
if self.mm == 13:
self.mm == 1
self.yy += 1
elif self.dd == 30 or self.dd == 31 or self.dd < 28
break
return self
today = Date()
today.display()
tomorrow = today + 365
tomorrow .display()