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

Have now incorporate year #642

Open
jameshughes89 opened this issue Dec 9, 2022 · 0 comments
Open

Have now incorporate year #642

jameshughes89 opened this issue Dec 9, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@jameshughes89
Copy link
Collaborator

From #640 and #641.

It was observed by @twentylemon that the calculation for the time duckbot was alive (found here) has a potential problem since year is a parameter for the special days list but the now calculation (found here) does not make use of the year.

As additionally noted by @twentylemon:

So what I mean here for year, this method mutates this class, adding dates to some internal map like {"2020-01-01": ["New Year's"]}. This method is lazily called when you ask for a date in a particular year.
So let's imagine a typical use case.

days = holidays.get(today_in_2022)
# ... the next day
days = holidays.get(tomorrow_in_2022)

The first call ends up populating the special days for 2022. DuckBot's inception day gets some value like "I'm n seconds old". In the second call, there's no need to populate the days again, so it is not called. Say tomorrow is DuckBot's special day, we end up saying "I'm n seconds old", but it's actually n+1 day seconds. now() is not recalculated.
DuckBot currently turns off every day, but already was not the case in the past, so we can't rely on _populate being called daily. We also can't force call it, since self[date] = x actually appends to the internal list of days the class keeps. now() needs to somehow be based on the year. We could just say datetime(year, 12, 3, 7, 0), but that also loses accuracy. Not sure what the best approach is here.

@twentylemon twentylemon added the bug Something isn't working label Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants