Version 1.1.0
- Made compatible with Python 3.8 (uses 3.10 typing from __future__) - Made uuid7.time() also verify variant, to more reliably reject invalid UUIDs - Changed repository names and links to uuid7-standard to match the package name
This commit is contained in:
parent
94f31c7d0b
commit
fcf47d78b0
@ -1,9 +1,9 @@
|
||||
[project]
|
||||
name = "uuid7-standard"
|
||||
version = "1.0.0"
|
||||
version = "1.1.0"
|
||||
description = "UUIDv7 with the final standard. Not to be confused with the uuid7 package on pypi, based on a draft version that was very different."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
requires-python = ">=3.8"
|
||||
dependencies = []
|
||||
authors = [
|
||||
{name = "Leo Vasanko"},
|
||||
@ -20,8 +20,8 @@ classifiers = [
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://git.zi.fi/leo/uuid7-python"
|
||||
Repository = "https://github.com/LeoVasanko/uuid7-python"
|
||||
Homepage = "https://git.zi.fi/LeoVasanko/uuid7-standard"
|
||||
Repository = "https://github.com/LeoVasanko/uuid7-standard"
|
||||
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
|
3
uuid7.py
3
uuid7.py
@ -1,3 +1,4 @@
|
||||
from __future__ import annotations
|
||||
from datetime import datetime
|
||||
from datetime import timezone as _tz
|
||||
from secrets import token_bytes as _token_bytes
|
||||
@ -28,7 +29,7 @@ def time(u: UUID | str) -> datetime:
|
||||
"""
|
||||
if not isinstance(u, UUID):
|
||||
u = UUID(u)
|
||||
if u.version != 7:
|
||||
if u.version != 7 or u.variant != "specified in RFC 4122":
|
||||
raise ValueError("Not a UUIDv7")
|
||||
ts = int.from_bytes(u.bytes[:6], "big")
|
||||
return datetime.fromtimestamp(ts / 1000, tz=_tz.utc)
|
||||
|
Loading…
x
Reference in New Issue
Block a user