Skip to content

Commit

Permalink
Fix boundary condition for start date after noon. Thanks @BernieVA (#52)
Browse files Browse the repository at this point in the history
This fix should address #43
  • Loading branch information
angerhang authored Jul 16, 2024
1 parent c8efbbc commit 949236d
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit 949236d

Please sign in to comment.