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

GH-124549: Add a note that when over-specifying datetime format, only the last directive gets used.#125009

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Mariatta wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
fromMariatta:123449-docs-about-dtformat

Conversation

Mariatta
Copy link
Member

@MariattaMariatta commentedOct 5, 2024
edited by bedevere-appbot
Loading

@bedevere-appbedevere-appbot added docsDocumentation in the Doc dir skip news awaiting core review labelsOct 5, 2024
@MariattaMariatta changed the titlegh-123549: Add a note that when over-specifying datetime format, only the last directive gets used.GH-124549: Add a note that when over-specifying datetime format, only the last directive gets used.Oct 5, 2024
@MariattaMariatta added 3.12only security fixes 3.13bugs and security fixes labelsOct 5, 2024
@alliesw
Copy link

from datetime import datetime

input_str = "200099"

Manually split the string

full_year = input_str[:4] # First 4 characters represent the full year
short_year = input_str[4:] # Last 2 characters represent the short year

Parse separately

date_full = datetime.strptime(full_year, "%Y")
date_short = datetime.strptime(short_year, "%y")

Now, handle both years according to your requirements

print(date_full) # Output: 2000-01-01 00:00:00
print(date_short) # Output: 1999-01-01 00:00:00

Here I'm just separately parsing both parts of the year and then I guess you apply them as needed?

@@ -2761,6 +2761,14 @@ Notes:
:exc:`DeprecationWarning`. In 3.15 or later we may change this into
an error or change the default year to a leap year. See :gh:`70647`.

(11)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Is a note here the best place for this?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@StanFromIrelandStanFromIrelandStanFromIreland left review comments

@pgansslepganssleAwaiting requested review from pgansslepganssle is a code owner

@abalkinabalkinAwaiting requested review from abalkinabalkin is a code owner

Assignees
No one assigned
Labels
3.12only security fixes3.13bugs and security fixesawaiting core reviewdocsDocumentation in the Doc dirskip news
Projects
Status: Todo
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@Mariatta@alliesw@StanFromIreland

[8]ページ先頭

©2009-2025 Movatter.jp