Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new Discord timestamps #39

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 8 additions & 4 deletions githubcards/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def format_issue_class(issue: dict) -> IssueData:
mergeable_state=mergeable_state,
milestone=milestone_title,
labels=labels,
created_at=datetime.strptime(issue['createdAt'], '%Y-%m-%dT%H:%M:%SZ')
created_at=datetime.strptime(issue['createdAt'], '%Y-%m-%dT%H:%M:%S%z')
)
return data

Expand All @@ -73,8 +73,6 @@ def format_issue(issue_data: IssueData) -> discord.Embed:
else:
embed.description = issue_data.body_text
embed.colour = getattr(IssueStateColour, issue_data.state)
formatted_datetime = issue_data.created_at.strftime('%d %b %Y, %H:%M')
embed.set_footer(text=f"{issue_data.name_with_owner} • Created on {formatted_datetime}")
if issue_data.labels:
embed.add_field(
name=f"Labels [{len(issue_data.labels)}]",
Expand All @@ -86,7 +84,13 @@ def format_issue(issue_data: IssueData) -> discord.Embed:
mergable_state = "Drafted"
embed.add_field(name="Merge Status", value=mergable_state)
if issue_data.milestone:
embed.add_field(name="Milestone", value=issue_data.milestone)
embed.add_field(name="Milestone", value=issue_data.milestone)
formatted_datetime = f"<t:{int(issue_data.created_at.timestamp())}:f>"
embed.add_field(
name="\u200b",
value=f"{issue_data.name_with_owner} • Created on {formatted_datetime}",
inline=False,
)
return embed

@staticmethod
Expand Down