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

DM-42836: Add calcPreviousDay convenience function #81

Merged
merged 2 commits into from Feb 20, 2024

Conversation

mfisherlevine
Copy link
Contributor

No description provided.

@@ -498,10 +498,31 @@ def calcNextDay(dayObs):
The next dayObs, as an integer, e.g. 20240101
"""
d1 = datetime.datetime.strptime(str(dayObs), '%Y%m%d')
oneDay = datetime.timedelta(days=1)
negative = -1 if previous else 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably too late for this to be worthwhile, but an offsetDayObs(dayObs, offsetInDays=1) function that took an integer number of days would be even simpler to implement, a bit more general, and just as easy to use.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's a very fair point and minimal work. I've made that function, and just redirected the next/previous day functions to call that function with +/- 1 so there's still nicely readable wrappers for it.

@mfisherlevine mfisherlevine merged commit c768bb8 into main Feb 20, 2024
1 check passed
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.

None yet

2 participants