#days #6 mah aval, 31 rooze (month > 0 and month <=6) #5 mah badi, 30 rooze (month > 6 and month <=11) #mah akhar 29 rooze (month == 12) #months #month <=12 and month >=1 class date: def __init__(self, day=31, month=6, year=1399): self.year = year self.month = month self.day = day @property def day(self): return self.__day @day.setter def day(self, day): self.__day=day if self.month>0 and self.month<7: tmp = self.day//31 for i in range(tmp): self.month +=1 if (self.day/31)==tmp: self.__day=1 else: self.__day = self.day-tmp*31 elif self.month<12: tmp = self.day//30 for i in range(tmp): self.month +=1 if (self.day/30)==tmp: self.__day=1 else: self.__day = self.day-tmp*30 else: tmp = self.day//29 for i in range(tmp): self.month +=1 if (self.day/29)==tmp: self.__day=1 else: self.__day = self.day-tmp*29 @property def month(self): return self.__month @month.setter def month(self, month): self.__month = month if(self.month >12): tmp = self.month//12 for i in range(tmp): self.year +=1 if (self.month/12)==tmp: self.__month=1 else: self.__month = self.month-tmp*12 @property def year(self): return self.__year @year.setter def year(self, year): self.__year = year def __repr__(self): return f"{self.year}/{self.month}/{self.day}" def __abs__(self): daysPassed = self.year*365 daysPassed = daysPassed + self.month*31 daysPassed = daysPassed + self.day return daysPassed def __eq__(self, secondDate):#date1 == date2 return self.__abs__() == secondDate.__abs__() def tik(self): self.day += 1 Date = date(58,11,1399) print(Date)