If you assign the date with self.date = datetime.date(*date)
, then you can create a Work_day
by passing a (year,month,day) tuple:
day = Work_day((2013,5,31), 8.0, 8.25)
Alternatively, if you want the input to be a date string, use datetime.strptime
, an appropriate formatting string, and the date()
method to get a date
object:
self.date = datetime.datetime.strptime(date,'%m/%d/%Y').date()
...
date = Work_day('5/31/2013', 8.0, 8.25)
Finally, you could just pass a date object:
day = Work_day(datetime.date(2013,5,31), 8.0, 8.25)
...
self.date = date
The Timesheet
class should work after any of these changes. show_days
still needs some work, but I'll leave that as an exercise. Hint: Parse the input dates with strptime
.