27 lines
490 B
Python
27 lines
490 B
Python
from datetime import timedelta
|
|
from django.utils import timezone
|
|
|
|
|
|
def get_shift_date_range(schedule="daily"):
|
|
|
|
now = timezone.now()
|
|
|
|
today_8am = now.replace(
|
|
hour=8,
|
|
minute=0,
|
|
second=0,
|
|
microsecond=0
|
|
)
|
|
|
|
if schedule.lower() == "daily":
|
|
|
|
start_date = today_8am - timedelta(days=1)
|
|
end_date = today_8am
|
|
|
|
else:
|
|
|
|
start_date = today_8am
|
|
end_date = today_8am + timedelta(days=1)
|
|
|
|
|
|
return start_date, end_date |