Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow datetime.date for different localtime functions #179

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bagdenaj
Copy link

@bagdenaj bagdenaj commented Dec 6, 2024

Some of the functions in the localtime module insist on datetime.datetime inputs when datetime.date also works. This PR aims to make these functions more flexible to avoid things like:

some_date = datetime.date(2024, 12, 6)
end_of_month = localtime.end_of_month(localtime.midnight(some_date))

@bagdenaj bagdenaj marked this pull request as draft December 6, 2024 10:17
@bagdenaj bagdenaj force-pushed the allow_date_in_serveral_localtime_functions branch 2 times, most recently from 9094bfd to 7f5cdb0 Compare December 6, 2024 10:36
@bagdenaj bagdenaj marked this pull request as ready for review December 6, 2024 10:38
@bagdenaj bagdenaj force-pushed the allow_date_in_serveral_localtime_functions branch 2 times, most recently from d61b9c7 to bb8bd5c Compare December 10, 2024 10:23
This aims to make those functionss more flexible so that we avoid having to transforming dates into
datetime before being able to pass them to those functions. Previously in our codebase this would
look like this for exmaple:

date = datetime.date(2024,7 ,9)
start_of_month = localtime.start_of_month(localtime.midnight(date))

Now it gets shorter to just:

date = datetime.date(2024,7 ,9)
start_of_month = localtime.start_of_month(date)
@bagdenaj bagdenaj force-pushed the allow_date_in_serveral_localtime_functions branch from bb8bd5c to 558b1cf Compare December 10, 2024 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant