Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ulid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def parse(cls: type[U], value: Any) -> U:
return cls.from_bytes(value)
raise TypeError(f"Cannot parse ULID from type {type(value)}")

@property
@functools.cached_property
def milliseconds(self) -> int:
"""The timestamp part as epoch time in milliseconds.

Expand All @@ -201,7 +201,7 @@ def milliseconds(self) -> int:
"""
return int.from_bytes(self.bytes[: constants.TIMESTAMP_LEN], byteorder="big")

@property
@functools.cached_property
def timestamp(self) -> float:
"""The timestamp part as epoch time in seconds.

Expand All @@ -212,7 +212,7 @@ def timestamp(self) -> float:
"""
return self.milliseconds / constants.MILLISECS_IN_SECS

@property
@functools.cached_property
def datetime(self) -> datetime:
"""Return the timestamp part as timezone-aware :class:`datetime` in UTC.

Expand All @@ -223,7 +223,7 @@ def datetime(self) -> datetime:
"""
return datetime.fromtimestamp(self.timestamp, timezone.utc)

@property
@functools.cached_property
def hex(self) -> str:
"""Encode the :class:`ULID`-object as a 32 char sequence of hex values."""
return self.bytes.hex()
Expand Down