diff options
author | 2021-07-17 22:42:05 +0100 | |
---|---|---|
committer | 2021-07-17 22:42:05 +0100 | |
commit | 579c04e0fde591e50af398c54d61843f20c66a1f (patch) | |
tree | d0694c25e9a78a8028fff40fc82436d4c3b990d6 | |
parent | fix: correctly expand home to find kubeconfig (diff) |
feat: add discord timestamp utility function
-rw-r--r-- | arthur/utils.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/arthur/utils.py b/arthur/utils.py index 12e2646..ea545b5 100644 --- a/arthur/utils.py +++ b/arthur/utils.py @@ -1,5 +1,7 @@ """Utility functionality for King Arthur.""" +from datetime import datetime + from discord import Embed from discord.colour import Colour @@ -9,3 +11,8 @@ def generate_error_embed( ) -> Embed: """Generate an error embed to return to Discord.""" return Embed(title=title, description=description, colour=Colour.red()) + + +def datetime_to_discord(time: datetime, format: str = "f") -> str: + """Convert a datetime object to a Discord timestamp.""" + return f"<t:{int(time.timestamp())}:{format}>" |