Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix DayToken addition so it handles changes in month and year #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions timefhuman/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def share(self, property, other, setter=setattr):
setter(self, property, others)
elif others is None and mine is not None:
setter(other, property, mine)

def isnumeric(self):
return False

Expand Down Expand Up @@ -178,7 +178,9 @@ def __add__(self, other):
3/5
"""
assert isinstance(other, int)
return DayToken(self.month, self.day + other, self.year)
d = datetime.date(self.year, self.month, self.day)
d = d + datetime.timedelta(days=other)
return DayToken(d.month, d.day, d.year)

def __radd__(self, other):
"""
Expand All @@ -187,7 +189,9 @@ def __radd__(self, other):
3/5
"""
assert isinstance(other, int)
return DayToken(self.month, self.day + other, self.year)
d = datetime.date(self.year, self.month, self.day)
d = d + datetime.timedelta(days=other)
return DayToken(d.month, d.day, d.year)

def datetime(self, now):
return datetime.datetime(self.year, self.month, self.day)
Expand Down