|
17 | 17 | # You should have received a copy of the GNU Lesser Public License
|
18 | 18 | # along with this program. If not, see [http://www.gnu.org/licenses/].
|
19 | 19 | """This module contains an object that represents a Telegram Birthday."""
|
20 |
| -from datetime import datetime |
| 20 | +from datetime import date |
21 | 21 | from typing import Optional
|
22 | 22 |
|
23 | 23 | from telegram._telegramobject import TelegramObject
|
@@ -70,19 +70,23 @@ def __init__(
|
70 | 70 |
|
71 | 71 | self._freeze()
|
72 | 72 |
|
73 |
| - def to_date(self, year: Optional[int] = None) -> datetime: |
| 73 | + def to_date(self, year: Optional[int] = None) -> date: |
74 | 74 | """Return the birthdate as a datetime object.
|
75 | 75 |
|
| 76 | + .. versionchanged:: NEXT.VERSION |
| 77 | + Now returns a :obj:`datetime.date` object instead of a :obj:`datetime.datetime` object, |
| 78 | + as was originally intended. |
| 79 | +
|
76 | 80 | Args:
|
77 | 81 | year (:obj:`int`, optional): The year to use. Required, if the :attr:`year` was not
|
78 | 82 | present.
|
79 | 83 |
|
80 | 84 | Returns:
|
81 |
| - :obj:`datetime.datetime`: The birthdate as a datetime object. |
| 85 | + :obj:`datetime.date`: The birthdate as a date object. |
82 | 86 | """
|
83 | 87 | if self.year is None and year is None:
|
84 | 88 | raise ValueError(
|
85 | 89 | "The `year` argument is required if the `year` attribute was not present."
|
86 | 90 | )
|
87 | 91 |
|
88 |
| - return datetime(year or self.year, self.month, self.day) # type: ignore[arg-type] |
| 92 | + return date(year or self.year, self.month, self.day) # type: ignore[arg-type] |
0 commit comments