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

[doc] Incorrect documentation for strftime()/strptime() format code %f #77562

Closed
jujuwoman mannequin opened this issue Apr 29, 2018 · 8 comments
Closed

[doc] Incorrect documentation for strftime()/strptime() format code %f #77562

jujuwoman mannequin opened this issue Apr 29, 2018 · 8 comments
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@jujuwoman
Copy link
Mannequin

jujuwoman mannequin commented Apr 29, 2018

BPO 33381
Nosy @freddrake, @MojoVampire, @pganssle, @miss-islington, @jujuwoman, @iritkatriel, @vishalpandeyvip
PRs
  • bpo-33381: [doc] strftime's %f option may pad zeros on the left or the right #29801
  • [3.10] bpo-33381: [doc] strftime's %f option may pad zeros on the left or the right (GH-29801) #29862
  • [3.9] bpo-33381: [doc] strftime's %f option may pad zeros on the left or the right (GH-29801) #29863
  • Files
  • Bug description.py: MWE of the bug
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-11-30.11:51:15.436>
    created_at = <Date 2018-04-29.01:06:18.507>
    labels = ['easy', 'type-bug', '3.9', '3.10', '3.11', 'library', 'docs']
    title = '[doc] Incorrect documentation for strftime()/strptime() format code %f'
    updated_at = <Date 2021-11-30.11:51:15.435>
    user = 'https://github.com/jujuwoman'

    bugs.python.org fields:

    activity = <Date 2021-11-30.11:51:15.435>
    actor = 'iritkatriel'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2021-11-30.11:51:15.436>
    closer = 'iritkatriel'
    components = ['Documentation', 'Library (Lib)']
    creation = <Date 2018-04-29.01:06:18.507>
    creator = 'jujuwoman'
    dependencies = []
    files = ['47556']
    hgrepos = []
    issue_num = 33381
    keywords = ['patch', 'easy', 'newcomer friendly']
    message_count = 8.0
    messages = ['315873', '316110', '321106', '407353', '407357', '407362', '407363', '407364']
    nosy_count = 8.0
    nosy_names = ['fdrake', 'docs@python', 'josh.r', 'p-ganssle', 'miss-islington', 'jujuwoman', 'iritkatriel', 'vishalpandeyvip']
    pr_nums = ['29801', '29862', '29863']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue33381'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @jujuwoman
    Copy link
    Mannequin Author

    jujuwoman mannequin commented 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.

    @jujuwoman jujuwoman mannequin added the type-bug An unexpected behavior, bug, or error label Apr 29, 2018
    @MojoVampire
    Copy link
    Mannequin

    MojoVampire mannequin commented May 3, 2018

    Note: strftime follows the existing documentation:

    >>> datetime.datetime(1970, 1, 1, microsecond=1).strftime('%f')
    '000001'

    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
    Copy link
    Member

    pganssle commented 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:

    >>> datetime(2018, 1, 1, 0, 0, 0, 1).strftime('%f')
    '000001'
    
    >>> datetime(2018, 1, 1, 0, 0, 0, 100000).strftime('%f')
    '100000'

    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.

    @iritkatriel iritkatriel added easy 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir stdlib Python modules in the Lib dir labels Nov 23, 2021
    @iritkatriel iritkatriel changed the title Incorrect documentation for strftime()/strptime() format code %f [doc] Incorrect documentation for strftime()/strptime() format code %f Nov 23, 2021
    @vishalpandeyvip
    Copy link
    Mannequin

    vishalpandeyvip mannequin commented Nov 30, 2021

    I have made a PR into the repository, can anyone please review and merge it.

    @iritkatriel
    Copy link
    Member

    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
    Copy link
    Member

    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
    Copy link
    Member

    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
    Copy link
    Member

    Thank you Judy and Vishal!

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants