You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[doc] Incorrect documentation for strftime()/strptime() format code %f #77562
The strptime behavior bug seems like a duplicate of bpo-32267, which claims to be fixed in master as of early January; may not have made it into a release yet though. I can't figure out how to view the patch on that issue, it doesn't seem to be linked to GitHub like normal.
In the first case "1" got expanded to "000001" and "100000" was printed as-is. However, when you interpret it as being *after* the decimal point, you would consider the first one to not be zero-padded at all and the second one to be zero-padded on the right.
I think the documentation can just be changed to "zero-padded to 6 digits" without specifying left or right.
changed the title [-]Incorrect documentation for strftime()/strptime() format code %f[/-][+][doc] Incorrect documentation for strftime()/strptime() format code %f[/+]on Nov 23, 2021
New changeset f97ec09 by Vishal Pandey in branch 'main': bpo-33381: [doc] strftime's %f option may pad zeros on the left or the right (GH-29801) f97ec09
New changeset 3975142 by Miss Islington (bot) in branch '3.10': bpo-33381: [doc] strftime's %f option may pad zeros on the left or the right (GH-29801) (GH-29862) 3975142
New changeset 031e2bb by Miss Islington (bot) in branch '3.9': bpo-33381: [doc] strftime's %f option may pad zeros on the left or the right (GH-29801) (GH-29863) 031e2bb
Activity
jujuwoman commentedon Apr 29, 2018
According to https://docs.python.org/3/library/datetime.html, %f is zero-padded on the left. But actual Python 3 behavior is puts the zero padding on the right.
MojoVampire commentedon May 3, 2018
Note: strftime follows the existing documentation:
The strptime behavior bug seems like a duplicate of bpo-32267, which claims to be fixed in master as of early January; may not have made it into a release yet though. I can't figure out how to view the patch on that issue, it doesn't seem to be linked to GitHub like normal.
pganssle commentedon Jul 5, 2018
I don't believe this is a duplicate if bpo-32267, which is actually about the %z directive.
I think the implementation here is correct and the documentation is semi-correct, it depends on how you look at it, consider:
In the first case "1" got expanded to "000001" and "100000" was printed as-is. However, when you interpret it as being *after* the decimal point, you would consider the first one to not be zero-padded at all and the second one to be zero-padded on the right.
I think the documentation can just be changed to "zero-padded to 6 digits" without specifying left or right.
[-]Incorrect documentation for strftime()/strptime() format code %f[/-][+][doc] Incorrect documentation for strftime()/strptime() format code %f[/+]vishalpandeyvip commentedon Nov 30, 2021
I have made a PR into the repository, can anyone please review and merge it.
iritkatriel commentedon Nov 30, 2021
New changeset f97ec09 by Vishal Pandey in branch 'main':
bpo-33381: [doc] strftime's %f option may pad zeros on the left or the right (GH-29801)
f97ec09
iritkatriel commentedon Nov 30, 2021
New changeset 3975142 by Miss Islington (bot) in branch '3.10':
bpo-33381: [doc] strftime's %f option may pad zeros on the left or the right (GH-29801) (GH-29862)
3975142
iritkatriel commentedon Nov 30, 2021
New changeset 031e2bb by Miss Islington (bot) in branch '3.9':
bpo-33381: [doc] strftime's %f option may pad zeros on the left or the right (GH-29801) (GH-29863)
031e2bb
iritkatriel commentedon Nov 30, 2021
Thank you Judy and Vishal!