Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

unexpected behavior ofdatetime.astimezone method #130718

Open
Labels
3.12only security fixes3.13bugs and security fixes3.14bugs and security fixesextension-modulesC modules in the Modules dirstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error
@donBarbos

Description

@donBarbos

Bug report

Bug description:

my system time zone isUTC+04:00

>>>importdatetime>>>datetime.datetime(9999,12,31).astimezone()# same for .astimezone(datetime.UTC)Traceback (mostrecentcalllast):File"<python-input-46>",line1,in<module>datetime.datetime(9999,12,31).astimezone()~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ValueError:yearmustbein1..9999,not10000>>>datetime.datetime(9999,12,31,tzinfo=datetime.UTC).astimezone()datetime.datetime(9999,12,31,4,0,tzinfo=datetime.timezone(datetime.timedelta(seconds=14400),'+04'))

same behavior for_pydatetime module, but I found that in version3.11 the behavior is as next:

>>>datetime.datetime(9999,12,31).astimezone()datetime.datetime(9999,12,31,0,0,tzinfo=datetime.timezone(datetime.timedelta(seconds=14400),'+04'))

EDIT: same behavior fordatetime(1, 1, 1):

>>>datetime.datetime(1,1,1).astimezone()Traceback (mostrecentcalllast):File"<python-input-23>",line1,in<module>datetime.datetime(1,1,1).astimezone()~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ValueError:yearmustbein1..9999,not0

CPython versions tested on:

CPython main branch, 3.13, 3.12

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixes3.14bugs and security fixesextension-modulesC modules in the Modules dirstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp