mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2025-02-16 10:19:17 +01:00
Fixing a bug to differentiate between 23:59:59 and 24:00:00 end times
This commit is contained in:
parent
cf81e0d452
commit
f4bde19511
@ -198,6 +198,8 @@ def convert_value(value):
|
|||||||
def daily_time_spent_calculation(earliest, latest, open_hours):
|
def daily_time_spent_calculation(earliest, latest, open_hours):
|
||||||
"""Returns the number of seconds for a single day time interval according to open hours."""
|
"""Returns the number of seconds for a single day time interval according to open hours."""
|
||||||
|
|
||||||
|
time_spent_seconds = 0
|
||||||
|
|
||||||
# avoid rendering day in different locale
|
# avoid rendering day in different locale
|
||||||
weekday = ('monday', 'tuesday', 'wednesday', 'thursday',
|
weekday = ('monday', 'tuesday', 'wednesday', 'thursday',
|
||||||
'friday', 'saturday', 'sunday')[earliest.weekday()]
|
'friday', 'saturday', 'sunday')[earliest.weekday()]
|
||||||
@ -215,8 +217,12 @@ def daily_time_spent_calculation(earliest, latest, open_hours):
|
|||||||
|
|
||||||
# translate time for delta calculation
|
# translate time for delta calculation
|
||||||
earliest_f = earliest.hour + earliest.minute / 60 + earliest.second / 3600
|
earliest_f = earliest.hour + earliest.minute / 60 + earliest.second / 3600
|
||||||
latest_f = latest.hour + latest.minute / 60 + latest.second / 3600
|
latest_f = latest.hour + latest.minute / 60 + latest.second / (60 * 60) + latest.microsecond / (60 * 60 * 999999)
|
||||||
|
|
||||||
|
# if latest time is midnight, add a second to the time spent
|
||||||
|
if latest_f >= 24:
|
||||||
|
time_spent_seconds += 1
|
||||||
|
|
||||||
if earliest_f < start:
|
if earliest_f < start:
|
||||||
earliest = earliest.replace(hour=start_hour, minute=start_minute, second=start_second)
|
earliest = earliest.replace(hour=start_hour, minute=start_minute, second=start_second)
|
||||||
elif earliest_f >= end:
|
elif earliest_f >= end:
|
||||||
@ -230,8 +236,6 @@ def daily_time_spent_calculation(earliest, latest, open_hours):
|
|||||||
day_delta = latest - earliest
|
day_delta = latest - earliest
|
||||||
|
|
||||||
# returns up to 86399 seconds, add one second if full day
|
# returns up to 86399 seconds, add one second if full day
|
||||||
time_spent_seconds = day_delta.seconds
|
time_spent_seconds += day_delta.seconds
|
||||||
if time_spent_seconds == 86399:
|
|
||||||
time_spent_seconds += 1
|
|
||||||
|
|
||||||
return time_spent_seconds
|
return time_spent_seconds
|
@ -994,7 +994,7 @@ class FollowUp(models.Model):
|
|||||||
|
|
||||||
if helpdesk_settings.FOLLOWUP_TIME_SPENT_AUTO and not self.time_spent:
|
if helpdesk_settings.FOLLOWUP_TIME_SPENT_AUTO and not self.time_spent:
|
||||||
self.time_spent = self.time_spent_calculation()
|
self.time_spent = self.time_spent_calculation()
|
||||||
|
|
||||||
super(FollowUp, self).save(*args, **kwargs)
|
super(FollowUp, self).save(*args, **kwargs)
|
||||||
|
|
||||||
def get_markdown(self):
|
def get_markdown(self):
|
||||||
@ -1045,14 +1045,14 @@ class FollowUp(models.Model):
|
|||||||
# close single day case
|
# close single day case
|
||||||
end_day_time = latest
|
end_day_time = latest
|
||||||
else:
|
else:
|
||||||
end_day_time = earliest.replace(hour=23, minute=59, second=59)
|
end_day_time = earliest.replace(hour=23, minute=59, second=59, microsecond=999999)
|
||||||
elif day == days:
|
elif day == days:
|
||||||
start_day_time = latest.replace(hour=0, minute=0, second=0)
|
start_day_time = latest.replace(hour=0, minute=0, second=0)
|
||||||
end_day_time = latest
|
end_day_time = latest
|
||||||
else:
|
else:
|
||||||
middle_day_time = earliest + datetime.timedelta(days=day)
|
middle_day_time = earliest + datetime.timedelta(days=day)
|
||||||
start_day_time = middle_day_time.replace(hour=0, minute=0, second=0)
|
start_day_time = middle_day_time.replace(hour=0, minute=0, second=0)
|
||||||
end_day_time = middle_day_time.replace(hour=23, minute=59, second=59)
|
end_day_time = middle_day_time.replace(hour=23, minute=59, second=59, microsecond=999999)
|
||||||
|
|
||||||
if (start_day_time.strftime("%Y-%m-%d") not in holidays and
|
if (start_day_time.strftime("%Y-%m-%d") not in holidays and
|
||||||
prev_status not in exclude_statuses and
|
prev_status not in exclude_statuses and
|
||||||
|
Loading…
Reference in New Issue
Block a user