generated from hjess/PythonTemplateProject
[main] Flight Things
All checks were successful
Build, Push, and Deploy to Nomad / docker-nomad (push) Successful in 1m54s
All checks were successful
Build, Push, and Deploy to Nomad / docker-nomad (push) Successful in 1m54s
This commit is contained in:
23
inspiration/TingSomSkalTilføjes/calender_maker.py
Normal file
23
inspiration/TingSomSkalTilføjes/calender_maker.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import calendar
|
||||
from datetime import date, timedelta
|
||||
class CalenderMaker(object):
|
||||
def get_dates(self,year=2025,dest_day="Friday", orgin_day="Wednesday"):
|
||||
start_date = date.today() + timedelta(days=3)
|
||||
return_date = start_date + timedelta(days=365)
|
||||
dags_differens = timedelta(days=1)
|
||||
resultat = []
|
||||
current_date = start_date
|
||||
while current_date <= return_date:
|
||||
ugenummer = current_date.isocalendar()[1]
|
||||
ugedag = current_date.strftime("%A")
|
||||
if ugenummer % 2 != 0 and ugedag in [dest_day, orgin_day]:
|
||||
if ugedag == dest_day:
|
||||
resultat.append({'date': current_date.strftime('%Y-%m-%d'), 'orgin': 'CPH', 'dest': 'LIS','uge':ugenummer, 'month':current_date.month})
|
||||
|
||||
if ugedag == orgin_day:
|
||||
resultat.append( { 'date': current_date.strftime( '%Y-%m-%d' ), 'orgin': 'LIS', 'dest': 'CPH','uge':ugenummer,'month':current_date.month} )
|
||||
current_date += dags_differens
|
||||
return resultat
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user