Change snowflake_time and time_snowflake parameters to pos/kw-only

This commit is contained in:
Rapptz
2022-08-15 13:39:03 -04:00
parent 668196c14c
commit 5b56899676
2 changed files with 18 additions and 7 deletions

View File

@ -354,8 +354,12 @@ def oauth_url(
return url
def snowflake_time(id: int) -> datetime.datetime:
"""
def snowflake_time(id: int, /) -> datetime.datetime:
"""Returns the creation time of the given snowflake.
.. versionchanged:: 2.0
The ``id`` parameter is now positional-only.
Parameters
-----------
id: :class:`int`
@ -370,14 +374,18 @@ def snowflake_time(id: int) -> datetime.datetime:
return datetime.datetime.fromtimestamp(timestamp, tz=datetime.timezone.utc)
def time_snowflake(dt: datetime.datetime, high: bool = False) -> int:
def time_snowflake(dt: datetime.datetime, /, *, high: bool = False) -> int:
"""Returns a numeric snowflake pretending to be created at the given date.
When using as the lower end of a range, use ``time_snowflake(high=False) - 1``
to be inclusive, ``high=True`` to be exclusive.
When using as the higher end of a range, use ``time_snowflake(high=True) + 1``
to be inclusive, ``high=False`` to be exclusive
to be inclusive, ``high=False`` to be exclusive.
.. versionchanged:: 2.0
The ``high`` parameter is now keyword-only and the ``dt`` parameter is now
positional-only.
Parameters
-----------