8000 The time library documentation should include the field to catch microseconds in a date time string · Issue #115315 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
The time library documentation should include the field to catch microseconds in a date time string #115315
Closed
@TahomaSoft

Description

@TahomaSoft

Documentation

Summary

Add documentation of the %f field to convert microseconds in the time library.

Details

On this webpage (https://docs.python.org/3.10/library/time.html), the discussion of strptime and the conversion fields used (%H for hour, %Y for year, etc) doesn't include mention of the %f field to match microseconds. On my system, this is needed to convert back and forth from datetime to time.struct_time.

For example, the command sequence:

now =  datetime.now(timezone.utc).isoformat()
print (now)

Yields: 2024-02-12T00:18:44.621471+00:00

To convert this to unix time or the python time tuple, I need to use the strptime format string of "%Y-%m-%dT%H:%M:%S.%f%z"

In short, I advocate adding a brief discussion of the %f field, perhaps just in the table, to this section of the documentation.

This probably impacts documentation for other versions of python too.

Thank you!

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0