xlcalculator
xlcalculator copied to clipboard
function DATE returns a datetime but should return a number (serial)
Currently;
@xl.register()
@xl.validate_args
def DATE(
year: func_xltypes.XlNumber,
month: func_xltypes.XlNumber,
day: func_xltypes.XlNumber
) -> func_xltypes.XlDateTime:
"""Returns the sequential serial number that represents a particular date.
https://support.office.com/en-us/article/
date-function-e36c0c8c-4104-49da-ab83-82328b832349
"""
Should return
@xl.register()
@xl.validate_args
def DATE(
year: func_xltypes.XlNumber,
month: func_xltypes.XlNumber,
day: func_xltypes.XlNumber
) -> func_xltypes.XlNumber:
"""Returns the sequential serial number that represents a particular date.
https://support.office.com/en-us/article/
date-function-e36c0c8c-4104-49da-ab83-82328b832349
"""
Then you have to remove the concept of XlDateTime from the code completely and somehow manage that with formatters. XlDateTime is definitely the right return type and it knows how to convert itself to a number for algebraic operations.
Fair enough.
You are correct. func_xltypes.DateTime has an int.
I've not thought it through completely but sticking with that paradigm I think there we may need to consider adding an XLTime datatype. Excel has a datatype for time and the function TIME is supposed to return a decimal which is probably best managed in a similar way DATE manages the serial integer.
Tools down for tonight before I make an awful mess.