Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function TODAY returns a datetime but should return a serial number of date. #25

Open
bradbase opened this issue Nov 11, 2020 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@bradbase
Copy link
Owner

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)
@bradbase bradbase added the bug Something isn't working label Nov 11, 2020
@bradbase bradbase self-assigned this Nov 11, 2020
@strichter
Copy link
Collaborator

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.

@bradbase
Copy link
Owner Author

There are util functions converting serial/date and back.

I'l reassess my approach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants