Browse Source

Fix Amica day matching

Toni Fadjukoff 6 years ago
parent
commit
c180b79650
1 changed files with 11 additions and 2 deletions
  1. 11 2
      amica.py

+ 11 - 2
amica.py View File

11
     today = datetime.date.today()
11
     today = datetime.date.today()
12
     week_day = today.isocalendar()[2]
12
     week_day = today.isocalendar()[2]
13
     this_monday = today - datetime.timedelta(days=week_day-1)
13
     this_monday = today - datetime.timedelta(days=week_day-1)
14
-    week_date = this_monday.strftime("%Y-%m-%d")
14
+    date_strings = []
15
+    for i in range(7):
16
+        date = this_monday + datetime.timedelta(days=i)
17
+        date_strings.append(date.strftime("%Y-%m-%d"))
18
+
15
     restaurants = []
19
     restaurants = []
16
     for count, info in enumerate(restaurant_info):
20
     for count, info in enumerate(restaurant_info):
17
         title = info[0]
21
         title = info[0]
23
 
27
 
24
         week_foods = {}
28
         week_foods = {}
25
         lunch_menus = data["MenusForDays"]
29
         lunch_menus = data["MenusForDays"]
26
-        for week_day, lunch_menu in enumerate(lunch_menus):
30
+        for lunch_menu in lunch_menus:
31
+            date = lunch_menu["Date"].split("T")[0]
32
+            try:
33
+                week_day = date_strings.index(date)
34
+            except:
35
+                continue
27
             current_day_foods = []
36
             current_day_foods = []
28
             set_menus = lunch_menu["SetMenus"]
37
             set_menus = lunch_menu["SetMenus"]
29
             html = lunch_menu.get("Html", "")
38
             html = lunch_menu.get("Html", "")