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
Fix for #3719 #3720
Fix for #3719 #3720
Conversation
%-d is not a valid strftime format on windows.
@@ -215,7 +215,7 @@ def from_filename(self, filename, resources=None, **kw): | |||
resources['metadata']['name'] = notebook_name | |||
|
|||
modified_date = datetime.datetime.fromtimestamp(os.path.getmtime(filename)) | |||
resources['metadata']['modified_date'] = modified_date.strftime("%B %-d, %Y") | |||
resources['metadata']['modified_date'] = modified_date.strftime("%B %d, %Y") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it'll work on windows, but I think we'd want %e
here, instead (replace with a space instead of a leading zero). Try it with datetime.datetime(1921,01,01).strftime("%B %e, %Y")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm seeing the same thing on Python 2.7 / Win32:
In [8]: pd.datetime(1921,01,01).strftime("%B %e, %Y")
Traceback (most recent call last):
File "<ipython-input-8-509fca1c6706>", line 1, in <module>
pd.datetime(1921,01,01).strftime("%B %e, %Y")
ValueError: Invalid format string
In [9]: pd.datetime(1921,01,01).strftime("%B %-d, %Y")
Traceback (most recent call last):
File "<ipython-input-9-f5acce1b2c70>", line 1, in <module>
pd.datetime(1921,01,01).strftime("%B %-d, %Y")
ValueError: Invalid format string
In [10]: pd.datetime(1921,01,01).strftime("%B %d, %Y")
Out[10]: 'January 01, 1921'
ok, based on @dhirschfeld's feedback, %e isn't an option on windows, so I'm +1 on merging this. Will just let @jdfreder and @Carreau check in here if there are other consideration here before making the merge. |
I hate the fact that the - doesn't work on windows. I'm sad there isn't an alternative format specifier (from what I could find). The only option that would achieve what we want is using str.format() to insert the day as an integer... But that would be a bit confusing to read...
@ivanov @dhirschfeld @Carreau If this is just too ugly to bare, I'm 👍 for merging. Just note, this shows up as "June 01, 1990" in the Sphinx documents |
Merging now, I think this is the right fix. |
fix platform-dependent datefmt closes #3719
oh man, how do folks feel about doing |
PR if you feel like it. |
fix platform-dependent datefmt closes ipython#3719
%-d is not a valid strftime format on windows.