mirror of
https://github.com/aclist/dztui.git
synced 2026-10-25 12:12:31 +01:00
fix: date traversal logic
This commit is contained in:
1 parent
84c6a3868b
commit
0e58cf514e
1 file changed
+17
-10
+17
-10
@@ -117,6 +117,9 @@ class ServerClock:
|
|||||||
def get_values(self) -> tuple[int, int]:
|
def get_values(self) -> tuple[int, int]:
|
||||||
return self.cur_time.hour, self.cur_time.minute
|
return self.cur_time.hour, self.cur_time.minute
|
||||||
|
|
||||||
|
def get_datetime(self) -> datetime:
|
||||||
|
return self.cur_time
|
||||||
|
|
||||||
def get_time(self) -> time:
|
def get_time(self) -> time:
|
||||||
return self.cur_time.time()
|
return self.cur_time.time()
|
||||||
|
|
||||||
@@ -126,18 +129,22 @@ class ServerClock:
|
|||||||
|
|
||||||
if current_time > end_time:
|
if current_time > end_time:
|
||||||
end_time += timedelta(days=1)
|
end_time += timedelta(days=1)
|
||||||
|
|
||||||
while current_time < end_time:
|
while current_time < end_time:
|
||||||
factor = self.get_accel_factor(current_time)
|
factor = self.get_accel_factor(current_time)
|
||||||
|
day_start = datetime.combine(current_time.date(), DAY_START_TIME)
|
||||||
|
day_end = datetime.combine(current_time.date(), DAY_END_TIME)
|
||||||
|
|
||||||
edge = (
|
if current_time.time() < DAY_START_TIME:
|
||||||
DAY_END_TIME if current_time.time() < DAY_END_TIME else DAY_START_TIME
|
edge = day_start
|
||||||
)
|
elif current_time.time() < DAY_END_TIME:
|
||||||
|
edge = day_end
|
||||||
|
else:
|
||||||
|
edge = datetime.combine(
|
||||||
|
current_time.date() + timedelta(days=1), DAY_START_TIME
|
||||||
|
)
|
||||||
|
|
||||||
next_edge = datetime.combine(current_time.date(), edge)
|
chunk_end = min(end_time, edge)
|
||||||
|
|
||||||
if next_edge <= current_time:
|
|
||||||
next_edge += timedelta(days=1)
|
|
||||||
chunk_end = min(end_time, next_edge)
|
|
||||||
total += (chunk_end - current_time).total_seconds() / factor
|
total += (chunk_end - current_time).total_seconds() / factor
|
||||||
current_time = chunk_end
|
current_time = chunk_end
|
||||||
return timedelta(seconds=total)
|
return timedelta(seconds=total)
|
||||||
@@ -268,8 +275,8 @@ class TimePicker(Gtk.Box):
|
|||||||
time(
|
time(
|
||||||
hour=self.get_hour(),
|
hour=self.get_hour(),
|
||||||
minute=self.get_minute(),
|
minute=self.get_minute(),
|
||||||
second=d.second,
|
second=0,
|
||||||
microsecond=d.microsecond,
|
microsecond=0,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user