Skip to content

Provide parseable repr to datetime.timezone #53246

Closed

Description

@abalkin
BPO 9000
Nosy @tim-one, @doerwalter, @mdickinson, @abalkin, @pitrou, @devdanzin, @ezio-melotti, @merwok, @bitdancer, @durban, @4kir4
Dependencies
  • bpo-5094: datetime lacks concrete tzinfo implementation for UTC
  • Files
  • issue9000-proto.diff: Patch against sandbox datetime.py and test_dateime.py
  • issue9000.diff: Patch for the C code with tests
  • 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 = 'https://github.com/abalkin'
    closed_at = <Date 2010-07-06.23:21:34.981>
    created_at = <Date 2010-06-15.15:52:46.422>
    labels = ['easy', 'type-feature']
    title = 'Provide parseable repr to datetime.timezone'
    updated_at = <Date 2010-07-10.21:34:51.882>
    user = 'https://github.com/abalkin'

    bugs.python.org fields:

    activity = <Date 2010-07-10.21:34:51.882>
    actor = 'eric.araujo'
    assignee = 'belopolsky'
    closed = True
    closed_date = <Date 2010-07-06.23:21:34.981>
    closer = 'belopolsky'
    components = []
    creation = <Date 2010-06-15.15:52:46.422>
    creator = 'belopolsky'
    dependencies = ['5094']
    files = ['17882', '17888']
    hgrepos = []
    issue_num = 9000
    keywords = ['patch', 'easy']
    message_count = 6.0
    messages = ['107876', '107877', '109397', '109436', '109438', '109443']
    nosy_count = 16.0
    nosy_names = ['tim.peters', 'doerwalter', 'mark.dickinson', 'belopolsky', 'ggenellina', 'pitrou', 'techtonik', 'ajaksu2', 'kawai', 'ezio.melotti', 'eric.araujo', 'r.david.murray', 'rafe', 'daniel.urban', 'l0nwlf', 'akira']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue9000'
    versions = ['Python 3.2']

    Activity

    1. abalkin commented on Jun 15, 2010

      @abalkin
      MemberAuthor

      Recently added datetime.timezone class does not have a custom repr, so one gets

      >>> timezone.utc
      <datetime.timezone object at 0x100681ef0>

      instead of parseable

      datetime.timezone(datetime.timedelta(0))

      This is inconsistent with the way other classes in datetime module behave.

    2. self-assigned this
      on Jun 15, 2010
    3. abalkin commented on Jun 15, 2010

      @abalkin
      MemberAuthor

      Merged bpo-5094 nosy list.

    4. abalkin commented on Jul 6, 2010

      @abalkin
      MemberAuthor

      I am attaching a python prototype. I am following the convention in place for the other datetime classes of prepending the repr with 'datetime.'. This may not be ideal, but better than to introduce an inconsistency. The only question I think is worth considering is the representation of timezone.utc. I would like to have repr(timezone(timedelta(0))) == 'datetime.timezone.utc' even though currently timezone(timedelta(0)) and timezone.utc are different but equal objects. This is going to change, however. See bpo-9051.

      [1] http://bugs.python.org/issue5094#msg106411

    5. abalkin commented on Jul 6, 2010

      @abalkin
      MemberAuthor

      Attaching a C patch.

    6. abalkin commented on Jul 6, 2010

      @abalkin
      MemberAuthor

      Replacing the patch. The previously attached patch reverted bpo-9051 a bit too aggressively.

    7. abalkin commented on Jul 6, 2010

      @abalkin
      MemberAuthor

      Committed in r82617. Python version committed to sandbox in r82616.

    8. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    easytype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions