Initial commit
This commit is contained in:
27
accounts/utils.py
Normal file
27
accounts/utils.py
Normal file
@@ -0,0 +1,27 @@
|
||||
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
|
||||
Reference in New Issue
Block a user