Add command support for no-year birthdates

This commit is contained in:
Ske 2018-07-15 00:21:35 +02:00
parent f9a7bee99d
commit b8539ec525
2 changed files with 8 additions and 1 deletions

View File

@ -294,7 +294,13 @@ async def member_set(conn, message, member, args):
try:
value = datetime.strptime(value, "%Y-%m-%d").date()
except ValueError:
return False, "Invalid date. Date must be in ISO-8601 format (eg. 1999-07-25)."
try:
# Try again, adding 0001 as a placeholder year
# This is considered a "null year" and will be omitted from the info card
# Useful if you want your birthday to be displayed yearless.
value = value = datetime.strptime("0001-" + value, "%Y-%m-%d").date()
except ValueError:
return False, "Invalid date. Date must be in ISO-8601 format (eg. 1999-07-25)."
if prop == "avatar":
user = await parse_mention(value)

View File

@ -62,6 +62,7 @@ For example:
`pk;member set John color #ff0000` - Changes John's color to red.
`pk;member set John pronouns he/him` - Changes John's pronouns.
`pk;member set John birthdate 1996-02-27` - Changes John's birthdate to Feb 27, 1996. (Must be YYYY-MM-DD format).
`pk;member set John birthdate 02-27` - Changes John's birthdate to February 27th, with no year.
`pk;member set John avatar https://placekitten.com/400/400` - Changes John's avatar to a linked image.
`pk;member set John avatar @JohnsAccount` - Changes John's avatar to the avatar of the mentioned account."""),
("Removing a member",