xlcalculator
xlcalculator copied to clipboard
Function TODAY returns a datetime but should return a serial number of date.
Currently;
now = datetime.datetime.now
@xl.register()
def TODAY() -> func_xltypes.XlDateTime:
"""Returns the serial number of the current date.
https://support.office.com/en-us/article/
today-function-5eb3078d-a82c-4736-8930-2f51a028fdd9
"""
return now()
Needs to be
now = datetime.datetime.now
@xl.register()
def TODAY() -> func_xltypes.XlNumber:
"""Returns the serial number of the current date.
https://support.office.com/en-us/article/
today-function-5eb3078d-a82c-4736-8930-2f51a028fdd9
"""
date_and_time = now()
date = date_and_time.replace(
hour=0, minute=0, second=0, microsecond=0)
return utils.datetime_to_number(date)
I would advise you strongly against that. If you return integers for dates that you need to capture somewhere, somehow that the cell is to be formatted as a date. We might need an xlcalculator Date/Time type that knows how to convert itself to a number if needed, but I thought we had that already.
There are util functions converting serial/date and back.
I'l reassess my approach