Fix birthday formatting in list command

This commit is contained in:
Ske 2019-03-09 12:56:07 +01:00
parent 41e6b64ad6
commit b5f7bfd91b
2 changed files with 11 additions and 6 deletions

View File

@ -121,10 +121,7 @@ async def member_card(conn, member: Member) -> discord.Embed:
card.colour = int(member.color, 16)
if member.birthday:
bday_val = member.birthday.strftime("%b %d, %Y")
if member.birthday.year == 1:
bday_val = member.birthday.strftime("%b %d")
card.add_field(name="Birthdate", value=bday_val)
card.add_field(name="Birthdate", value=member.birthday_string())
if member.pronouns:
card.add_field(name="Pronouns", value=truncate_field_body(member.pronouns))
@ -236,7 +233,7 @@ def member_list(system: System, all_members: List[Member], current_page: int, pa
for member in all_members[current_page*page_size:current_page*page_size+page_size]:
member_description = "**ID**: {}\n".format(member.hid)
if member.birthday:
member_description += "**Birthday:** {}\n".format(member.birthday.isoformat())
member_description += "**Birthday:** {}\n".format(member.birthday_string())
if member.pronouns:
member_description += "**Pronouns:** {}\n".format(member.pronouns)
if member.description:

View File

@ -161,4 +161,12 @@ class Member(namedtuple("Member",
return await db.get_system(conn, self.system)
async def message_count(self, conn) -> int:
return await db.get_member_message_count(conn, self.id)
return await db.get_member_message_count(conn, self.id)
def birthday_string(self) -> Optional[str]:
if not self.birthday:
return None
if self.birthday.year == 1:
return self.birthday.strftime("%b %d")
return self.birthday.strftime("%b %d, %Y")