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

datetime.datetime.min.strftime('%Y') not working #63361

Closed
filipzyzniewski mannequin opened this issue Oct 4, 2013 · 3 comments
Closed

datetime.datetime.min.strftime('%Y') not working #63361

filipzyzniewski mannequin opened this issue Oct 4, 2013 · 3 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@filipzyzniewski
Copy link
Mannequin

filipzyzniewski mannequin commented Oct 4, 2013

BPO 19162
Nosy @bitdancer
Superseder
  • bpo-1777412: datetime.strftime dislikes years before 1900
  • 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 2013-10-04.14:02:48.849>
    created_at = <Date 2013-10-04.11:00:07.361>
    labels = ['type-bug', 'library']
    title = "datetime.datetime.min.strftime('%Y') not working"
    updated_at = <Date 2013-10-04.14:02:48.847>
    user = 'https://bugs.python.org/filipzyzniewski'

    bugs.python.org fields:

    activity = <Date 2013-10-04.14:02:48.847>
    actor = 'r.david.murray'
    assignee = 'none'
    closed = True
    closed_date = <Date 2013-10-04.14:02:48.849>
    closer = 'r.david.murray'
    components = ['Library (Lib)']
    creation = <Date 2013-10-04.11:00:07.361>
    creator = 'filip.zyzniewski'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 19162
    keywords = []
    message_count = 3.0
    messages = ['198941', '198944', '198951']
    nosy_count = 3.0
    nosy_names = ['r.david.murray', 'filip.zyzniewski', 'krzaq']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '1777412'
    type = 'behavior'
    url = 'https://bugs.python.org/issue19162'
    versions = ['Python 2.7', 'Python 3.2']

    @filipzyzniewski
    Copy link
    Mannequin Author

    filipzyzniewski mannequin commented Oct 4, 2013

    The datetime class provides a min datetime object which is not formattable:

    on Python 2:

    $ python
    Python 2.7.3 (default, Apr 10 2013, 05:13:16) 
    [GCC 4.7.2] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import datetime
    >>> datetime.datetime.min.strftime('%Y')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ValueError: year=1 is before 1900; the datetime strftime() methods require year >= 1900
    >>> 

    and on Python 3:

    $ python3
    Python 3.2.3 (default, Apr 10 2013, 05:07:54) 
    [GCC 4.7.2] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import datetime
    >>> datetime.datetime.min.strftime('%Y')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ValueError: year=1 is before 1000; the datetime strftime() methods require year >= 1000
    >>>

    It seems to me that either datetime.datetime.min.year should be increased to 1900/1000 or strftime should be able to format year=1 - it is strange that the API doesn't support its own constants.

    @filipzyzniewski filipzyzniewski mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Oct 4, 2013
    @krzaq
    Copy link
    Mannequin

    krzaq mannequin commented Oct 4, 2013

    works correctly on python3.3:
    Python 3.3.2 (default, Oct  4 2013, 12:21:07)
    [GCC 4.2.1 20070831 patched [FreeBSD]] on freebsd9
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import datetime
    >>> datetime.datetime.min.strftime('%Y')
    '0001'
    
    issue on 2.7:
    Python 2.7.5 (default, Sep 17 2013, 12:11:31)
    [GCC 4.2.1 20070831 patched [FreeBSD]] on freebsd9
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import datetime
    >>> datetime.datetime.min.strftime('%Y')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ValueError: year=1 is before 1900; the datetime strftime() methods require year >= 1900

    @bitdancer
    Copy link
    Member

    Indeed, this is already fixed. This issue is a duplicate of bpo-1777412. The bug will not be fixed in earlier versions for the reasons discussed in that issue.

    @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
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant