https://github.com/python/cpython/commit/fd1b98dd1df14c8e4138d779166635c98926197b commit: fd1b98dd1df14c8e4138d779166635c98926197b branch: main author: Bénédikt Tran <10796600+picn...@users.noreply.github.com> committer: picnixz <10796600+picn...@users.noreply.github.com> date: 2025-04-07T17:21:56+02:00 summary:
gh-130843: add UUIDv7 timestamp recipes (#132154) Co-authored-by: Hugo van Kemenade <1324225+hug...@users.noreply.github.com> files: M Doc/library/uuid.rst diff --git a/Doc/library/uuid.rst b/Doc/library/uuid.rst index 13c00d22ef0299..75ea27c7d39b18 100644 --- a/Doc/library/uuid.rst +++ b/Doc/library/uuid.rst @@ -121,8 +121,10 @@ which relays any information about the UUID's safety, using this enumeration: - The last 48 bits of the UUID. Only relevant to version 1. * - .. attribute:: UUID.time - - The 60-bit timestamp for version 1 and 6, - or the 48-bit timestamp for version 7. + - The 60-bit timestamp as a count of 100-nanosecond intervals since + Gregorian epoch (1582-10-15 00:00:00) for versions 1 and 6, or the + 48-bit timestamp in milliseconds since Unix epoch (1970-01-01 00:00:00) + for version 7. * - .. attribute:: UUID.clock_seq - The 14-bit sequence number. Only relevant to versions 1 and 6. @@ -434,6 +436,15 @@ Here are some examples of typical usage of the :mod:`uuid` module:: >>> uuid.MAX UUID('ffffffff-ffff-ffff-ffff-ffffffffffff') + >>> # get UUIDv7 creation (local) time as a timestamp in milliseconds + >>> u = uuid.uuid7() + >>> u.time # doctest: +SKIP + 1743936859822 + >>> # get UUIDv7 creation (local) time as a datetime object + >>> import datetime as dt + >>> dt.datetime.fromtimestamp(u.time / 1000) # doctest: +SKIP + datetime.datetime(...) + .. _uuid-cli-example: _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com