From 32e8b2e99c99751389f4d1b2d1871f75562fbb22 Mon Sep 17 00:00:00 2001
From: dusoleil <howcansocksbereal@gmail.com>
Date: Sat, 27 Aug 2022 01:23:22 -0400
Subject: Shift earlier records to the back if they would be before midnight
 after bias correction

---
 data_model/TimeSlot.gd | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'data_model/TimeSlot.gd')

diff --git a/data_model/TimeSlot.gd b/data_model/TimeSlot.gd
index ac1a008..6f92c81 100644
--- a/data_model/TimeSlot.gd
+++ b/data_model/TimeSlot.gd
@@ -36,4 +36,11 @@ static func get_by_schedule_name(schedule_name):
     var timeslots = []
     for record in records:
         timeslots.push_back(TimeSlot_data.new(record))
+    #shift earlier records to the back if they would be <12:00AM after bias correction
+    var bias = Time.get_time_zone_from_system().bias * 60
+    var tsi = 0
+    var tslen = timeslots.size()
+    while tsi < tslen && (timeslots[0].start_time + bias < 0):
+        tsi += 1
+        timeslots.push_back(timeslots.pop_front())
     return timeslots
-- 
cgit v1.2.3