I did create a new datetime.date
like object
class WorkDate(datetime.date):
pass
The functionality of this WorkDate
is(not important for this question) that when you add a timedelta
object it will only move to a weekday date. ie when you add a timedelta(1)
on a Friday dated WorkDate
it will return the next Monday dated WorkDate
.
How can I
__init__
WorkDate
by any one of these two method to create same result
x = WorkDate(2017, 8, 3)
y = WorkDate(datetime.date(2017, 8, 3))
I did try this but not working for initialization with date object
class WorkDate(datetime.date):
def __init__(self, *args):
if len(args) == 3:
super(WorkDate, self).__init__(args[0], args[1], args[2])
elif len(args) == 1:
self.year = args[0].year
self.month = args[0].month
self.day = args[0].day