Birthdate

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

Bases: telegram.TelegramObject

This object represents a user’s birthday.

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.

New 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 datetime object.

Parameters:

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

Returns:

The birthdate as a datetime object.

Return type:

datetime.datetime