diff --git a/bolt11/types.py b/bolt11/types.py index c93cd84..ba16cbb 100644 --- a/bolt11/types.py +++ b/bolt11/types.py @@ -16,11 +16,7 @@ from .models.features import Features from .models.routehint import RouteHint from .models.signature import Signature -from .models.tags import ( - Tag, # noqa: F401, F403 - TagChar, - Tags, -) +from .models.tags import TagChar, Tags class MilliSatoshi(int): @@ -98,8 +94,13 @@ def metadata(self) -> Optional[str]: tag = self.tags.get(TagChar.metadata) return tag.data if tag else None + # backwards compatibility @property def dt(self) -> datetime: + return self.date_time + + @property + def date_time(self) -> datetime: return datetime.fromtimestamp(self.date) @property @@ -113,6 +114,12 @@ def expiry_date(self) -> Optional[datetime]: return None return datetime.fromtimestamp(self.date + self.expiry) + @property + def expiry_time(self) -> Optional[int]: + if not self.expiry: + return None + return self.date + self.expiry + @property def features(self) -> Optional[Features]: tag = self.tags.get(TagChar.features)