Skip to content

Conversation

@StanFromIreland
Copy link
Member

@StanFromIreland StanFromIreland commented Mar 22, 2025

Cut down the diff removing duplicate tests (tests have been added since 2020...)

Applied Pauls suggestion from the other thread.

There was discussion about making it mandatory but that is a backwards compatibility nightmare! We can add this functionality now and in the future deprecate not using it if we wish to make it required.

Continues #32041


📚 Documentation preview 📚: https://cpython-previews--131585.org.readthedocs.build/

Conflicts resolved and NEWS updated.

Add an optional parameter to datetime.isoformat() and time.isoformat()
called use_utc_designator. If provided and True and the object is
associated with a tzinfo and its tzname is exactly "UTC", the formatted
UTC offset will be "Z" rather than an offset from UTC.
@StanFromIreland StanFromIreland marked this pull request as ready for review March 22, 2025 20:06
@StanFromIreland
Copy link
Member Author

cc @godlygeek Finishing off your work, I hope you don't mind :-)

@pganssle
Copy link
Member

We deliberately chose not to do this because we did a survey of the options and it was clear that there was not an option that people would find understandable.

@StanFromIreland
Copy link
Member Author

StanFromIreland commented Mar 23, 2025

Where was this survey done the only survey was a naming survey? The issue has overwhelming support? There was some discussion about the option naming so I can change it if there is a suggestion you consider better but the result from the naming survey didn’t receive much support in the thread itself, but I don’t mind utc_as_z. How can the only blocker be the option name?

There were people who wanted it to be the default behaviour but obviously we can’t just do that so this is a step in that direction.

@mohd-akram
Copy link

Another possible, shorter option:

datetime.isoformat(utc='z')

The default would be:

datetime.isoformat(utc='0')

.. versionchanged:: 3.6
Added the *timespec* argument.
.. versionchanged:: next
Added the *use_utc_designator* argument.
Copy link
Member

@merwok merwok Mar 24, 2025

Choose a reason for hiding this comment

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

Previous wording was correct I think: function definitions have parameters (hence ParamSpec in inspect), function calls take arguments.

OTOH text below uses argument so..

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants