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

Fix for #3719 #3720

Merged
merged 1 commit into from Jul 27, 2013
Merged

Fix for #3719 #3720

merged 1 commit into from Jul 27, 2013

Conversation

jstenar
Copy link
Member

@jstenar jstenar commented Jul 22, 2013

%-d is not a valid strftime format on windows.

%-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")
Copy link
Member

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")

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'

@ivanov
Copy link
Member

ivanov commented Jul 22, 2013

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.

@ghost ghost assigned Carreau Jul 25, 2013
@jdfreder
Copy link
Member

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...

d = pd.datetime(1921,01,01)
d.strftime("%B {0}, %Y").format(d.day)

@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

@minrk
Copy link
Member

minrk commented Jul 27, 2013

Merging now, I think this is the right fix.

minrk added a commit that referenced this pull request Jul 27, 2013
fix platform-dependent datefmt

closes #3719
@minrk minrk merged commit 8d0a6b7 into ipython:master Jul 27, 2013
@ivanov
Copy link
Member

ivanov commented Jul 27, 2013

oh man, how do folks feel about doing %d only for windows, and having the saner and cleaner %-d. I can have a PR ready

@minrk
Copy link
Member

minrk commented Jul 27, 2013

PR if you feel like it.

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants