Birthdate

class telegram.Birthdate(day, month, year=None, *, api_kwargs=None)[source]

Bases: telegram.TelegramObject

This object describes the birthdate of a user.

Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their day, and month are equal.

Added in version 21.1.

Parameters:
  • day (int) – Day of the user’s birth; 1-31.

  • month (int) – Month of the user’s birth; 1-12.

  • year (int, optional) – Year of the user’s birth.

day[source]

Day of the user’s birth; 1-31.

Type:

int

month[source]

Month of the user’s birth; 1-12.

Type:

int

year[source]

Optional. Year of the user’s birth.

Type:

int

to_date(year=None)[source]

Return the birthdate as a date object.

Changed in version 21.2: Now returns a datetime.date object instead of a datetime.datetime object, as was originally intended.

Parameters:

year (int, optional) – The year to use. Required, if the year was not present.

Returns:

The birthdate as a date object.

Return type:

datetime.date