diff --git a/aurora/aurora.py b/aurora/aurora.py index fe5c4ab..9b96ee7 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -1224,6 +1224,25 @@ class Aurora(commands.Cog): error("Please provide a valid GalacticBot moderation export file.") ) + @aurora.command(aliases=["dtc", "dt", "datetimeconvert"]) + async def datetime(self, ctx: commands.Context, *, date: str) -> None: + """Convert a string to a datetime object. + + This command converts a date to a [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime) Python object. + + **Example usage** + `[p]aurora datetime 08/20/2024` + **Output** + `2024-08-20 12:00:00`""" + try: + parsed_date = parse(date) + await ctx.send(f"`{parsed_date}`") + except (ParserError, OverflowError) as e: + if e == ParserError: + await ctx.send(error("Invalid date format!")) + if e == OverflowError: + await ctx.send(error("Date is too far in the future!")) + @aurora.command(aliases=["tdc", "td", "timedeltaconvert"]) async def timedelta(self, ctx: commands.Context, *, duration: str) -> None: """Convert a string to a timedelta.