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 :attr:`day`, and :attr:`month` are equal. .. versionadded:: 21.1 Args: day (:obj:`int`): Day of the user'
| 25 | |
| 26 | |
| 27 | class Birthdate(TelegramObject): |
| 28 | """ |
| 29 | This object describes the birthdate of a user. |
| 30 | |
| 31 | Objects of this class are comparable in terms of equality. Two objects of this class are |
| 32 | considered equal, if their :attr:`day`, and :attr:`month` are equal. |
| 33 | |
| 34 | .. versionadded:: 21.1 |
| 35 | |
| 36 | Args: |
| 37 | day (:obj:`int`): Day of the user's birth; 1-31. |
| 38 | month (:obj:`int`): Month of the user's birth; 1-12. |
| 39 | year (:obj:`int`, optional): Year of the user's birth. |
| 40 | |
| 41 | Attributes: |
| 42 | day (:obj:`int`): Day of the user's birth; 1-31. |
| 43 | month (:obj:`int`): Month of the user's birth; 1-12. |
| 44 | year (:obj:`int`): Optional. Year of the user's birth. |
| 45 | |
| 46 | """ |
| 47 | |
| 48 | __slots__ = ("day", "month", "year") |
| 49 | |
| 50 | def __init__( |
| 51 | self, |
| 52 | day: int, |
| 53 | month: int, |
| 54 | year: int | None = None, |
| 55 | *, |
| 56 | api_kwargs: JSONDict | None = None, |
| 57 | ): |
| 58 | super().__init__(api_kwargs=api_kwargs) |
| 59 | |
| 60 | # Required |
| 61 | self.day: int = day |
| 62 | self.month: int = month |
| 63 | # Optional |
| 64 | self.year: int | None = year |
| 65 | |
| 66 | self._id_attrs = ( |
| 67 | self.day, |
| 68 | self.month, |
| 69 | ) |
| 70 | |
| 71 | self._freeze() |
| 72 | |
| 73 | def to_date(self, year: int | None = None) -> dtm.date: |
| 74 | """Return the birthdate as a date object. |
| 75 | |
| 76 | .. versionchanged:: 21.2 |
| 77 | Now returns a :obj:`datetime.date` object instead of a :obj:`datetime.datetime` object, |
| 78 | as was originally intended. |
| 79 | |
| 80 | Args: |
| 81 | year (:obj:`int`, optional): The year to use. Required, if the :attr:`year` was not |
| 82 | present. |
| 83 | |
| 84 | Returns: |
no outgoing calls
searching dependent graphs…