-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/custom-changelogger
- Loading branch information
Showing
17 changed files
with
1,671 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import datetime | ||
import enum | ||
import typing | ||
|
||
import arrow | ||
|
||
|
||
class TimeStampEnum(enum.Enum): | ||
""" | ||
Timestamp modes for discord. | ||
Full docs on this format are viewable here: | ||
https://discord.com/developers/docs/reference#message-formatting | ||
""" | ||
|
||
# fmt: off | ||
SHORT_TIME = "t" # 16:20 | ||
LONG_TIME = "T" # 16:20:30 | ||
SHORT_DATE = "d" # 20/04/2021 | ||
LONG_DATE = "D" # 20 April 2021 | ||
SHORT_DATE_TIME = "f" # 20 April 2021 16:20 | ||
LONG_DATE_TIME = "F" # Tuesday, 20 April 2021 16:20 | ||
RELATIVE_TIME = "R" # 2 months ago | ||
|
||
# fmt: on | ||
# DEFAULT alised to the default, so for all purposes, it behaves like SHORT_DATE_TIME, including the name | ||
DEFAULT = SHORT_DATE_TIME | ||
|
||
|
||
TypeTimes = typing.Union[arrow.Arrow, datetime.datetime] | ||
|
||
|
||
def get_discord_formatted_timestamp( | ||
timestamp: TypeTimes, format: TimeStampEnum = TimeStampEnum.DEFAULT | ||
) -> str: | ||
""" | ||
Return a discord formatted timestamp from a datetime compatiable datatype. | ||
`format` must be an enum member of TimeStampEnum. Default style is SHORT_DATE_TIME | ||
""" | ||
return f"<t:{int(timestamp.timestamp())}:{format.value}>" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import pytest | ||
|
||
|
||
def pytest_report_header(config): | ||
def pytest_report_header(config) -> str: | ||
"""Pytest headers.""" | ||
return "package: modmail" |
Oops, something went wrong.