1class Date(object):
2
3 def __init__(self, day=0, month=0, year=0):
4 self.day = day
5 self.month = month
6 self.year = year
7
8 @classmethod
9 def from_string(cls, date_as_string):
10 day, month, year = map(int, date_as_string.split('-'))
11 date1 = cls(day, month, year)
12 return date1
13
14 @staticmethod
15 def is_date_valid(date_as_string):
16 day, month, year = map(int, date_as_string.split('-'))
17 return day <= 31 and month <= 12 and year <= 3999
18
19date2 = Date.from_string('11-09-2012')
20is_date = Date.is_date_valid('11-09-2012')