in darabonba/date.py [0:0]
def diff(self, unit, diff_date):
if unit in ["second", "seconds"]:
return int((self.date - diff_date.date).total_seconds())
elif unit in ["minute", "minutes"]:
return int((self.date - diff_date.date).total_seconds() / 60)
elif unit in ["hour", "hours"]:
return int((self.date - diff_date.date).total_seconds() / 3600)
elif unit in ["day", "days"]:
return int((self.date - diff_date.date).total_seconds() / (3600 * 24))
elif unit in ["week", "weeks"]:
return int((self.date - diff_date.date).total_seconds() / (3600 * 24 * 7))
elif unit in ["month", "months"]:
return (self.date.year - diff_date.date.year) * 12 + (self.date.month - diff_date.date.month)
elif unit in ["year", "years"]:
return self.date.year - diff_date.date.year