2025-01-21 21:04:40 +01:00
|
|
|
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)
|
2025-02-10 14:28:05 +01:00
|
|
|
days_diff = timedelta(days=1)
|
|
|
|
|
result = []
|
2025-01-21 21:04:40 +01:00
|
|
|
current_date = start_date
|
|
|
|
|
while current_date <= return_date:
|
2025-02-10 14:28:05 +01:00
|
|
|
week_no = current_date.isocalendar()[1]
|
|
|
|
|
weekday = current_date.strftime("%A")
|
|
|
|
|
if week_no % 2 != 0 and weekday in [dest_day, orgin_day]:
|
|
|
|
|
if weekday == dest_day:
|
|
|
|
|
result.append({'date': current_date.strftime('%Y-%m-%d'), 'departure': 'CPH', 'arrival': 'LIS','week_no':week_no, 'month':current_date.month})
|
|
|
|
|
if weekday == orgin_day:
|
|
|
|
|
result.append( { 'date': current_date.strftime( '%Y-%m-%d' ), 'departure': 'LIS', 'arrival': 'CPH','week_no':week_no,'month':current_date.month} )
|
|
|
|
|
current_date += days_diff
|
|
|
|
|
return result
|
2025-01-21 21:04:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|