I have three datetime oddities.
Note the form and code were copied verbatim across apps. Makes me think something has changed? If so I need to update all my apps, I assume.
First - one app works like this :
def link_thismonth_click (self, **event_args):
# This method is called when the link is clicked
self.date_picker_start.date=date(date.today().year, date.today().month, 1)
self.date_picker_end.date=datetime.now().date()
But a second requires str() else it blanks the date picker control text :
def link_thismonth_click (self, **event_args):
# This method is called when the link is clicked
self.date_picker_start.date=str(date(date.today().year, date.today().month, 1))
self.date_picker_end.date=str(datetime.now().date())
Why the difference?
Second issue - this works in the original app :
def link_eom_click (self, **event_args):
# This method is called when the link is clicked
fom = self.date_picker_start.date.replace(day=1)
eom = (fom + timedelta(days=33)).replace(day=1) - timedelta(days=1)
self.date_picker_start.date=fom
self.date_picker_end.date=eom
But the same code in the second app produces this error :
TypeError: unsupported operand type(s) for Add: 'date' and 'timedelta'
Finally, this code works in app 1 :
def link_endstart_click (self, **event_args):
# This method is called when the link is clicked
self.date_picker_end.date=self.date_picker_start.date
but produces this error in app 2 :
TypeError: Required argument 'struct_time' must be of type: 'struct_time'
at src/lib/datetime.py, line 253 column 4
called from src/lib/datetime.py, line 768 column 44