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

Fix boundary condition for start date after noon. Thanks @BernieVA #52

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/asleep/sleep_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@ def get_day_intervals(start_date, end_date, date_format):
my_day_end = pd.to_datetime(day_end_str, format=date_format)
my_day_start = start_date.replace(
hour=12, minute=0, second=0, microsecond=0)
my_day_start = my_day_start - timedelta(hours=24)

# if the start date is before 12:00 noon, then the interval start is 24 hours prior
if start_date.hour < 12:
my_day_start = my_day_start - timedelta(hours=24)

while my_day_end < end_date:
my_day_end = my_day_start + timedelta(hours=23, minutes=59, seconds=59)
Expand Down
Loading