-
-
Notifications
You must be signed in to change notification settings - Fork 485
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
Add proper support for datetime.time objects/ time-only cell formats #86
Comments
Note that appscript uses current date if only time is given |
Excel to Python returns a float in any case, not a datetime object. |
I'm looking to return @xw.func
def test_time():
return datetime.time(1, 2, 3)
@xw.func
def test_date():
return datetime.date(2001, 2, 3)
@xw.func
def test_datetime():
return datetime.datetime(2001, 2, 3, 4, 5, 6) |
Basically, the issue is that Excel doesn't have a time-only type. A time-only cell has the date 1/1/1900, so you should be able to send over a |
Thanks for the workaround! Any chance of getting that into I'm trying to make a PR but failing miserably so far. I can't figure out where the error originates. |
I added this to if type(dt_time) is dt.time:
# Excel does not have a time-only data type. It stores times with date `1900/01/01`.
dt_time = dt.datetime(1900, 1, 1, dt_time.hour, dt_time.minute, dt_time.second,
tzinfo=win32timezone.TimeZoneInfo.utc()) but it looks like the error is thrown before |
you'll also need to add or it's not triggering that conversion in: |
This feature will be really helpful, thanks |
On Mac, this is taken care of by appscript, but on Windows,
_datetime_to_com_time
doesn't handle this yet.The text was updated successfully, but these errors were encountered: