Skip to content

Commit 651eb82

Browse files
committed
Fixing days of the week
1 parent 6fcd070 commit 651eb82

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

featuremanagement/_time_window_filter/_models.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# license information.
55
# -------------------------------------------------------------------------
66
from enum import Enum
7-
from typing import Dict, Any
7+
from typing import Dict, Any, Optional
88
from datetime import datetime
99
from dataclasses import dataclass
1010
from email.utils import parsedate_to_datetime
@@ -68,13 +68,18 @@ class RecurrencePattern: # pylint: disable=too-few-public-methods
6868
The recurrence pattern settings.
6969
"""
7070

71+
days: list = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
72+
7173
def __init__(self, pattern_data: Dict[str, Any]):
7274
self.type = RecurrencePatternType.from_str(pattern_data.get("Type", "Daily"))
7375
self.interval = pattern_data.get("Interval", 1)
7476
if self.interval <= 0:
7577
raise ValueError("The interval must be greater than 0.")
76-
self.days_of_week = pattern_data.get("DaysOfWeek", [])
77-
self.first_day_of_week = pattern_data.get("FirstDayOfWeek", 7)
78+
days_of_week = pattern_data.get("DaysOfWeek", [])
79+
for day in days_of_week:
80+
self.days_of_week.append(self.days.index(day))
81+
first_day_of_week = pattern_data.get("FirstDayOfWeek", "Sunday")
82+
self.first_day_of_week = self.days.index(first_day_of_week) if first_day_of_week in self.days else 0
7883

7984

8085
class RecurrenceRange: # pylint: disable=too-few-public-methods
@@ -110,7 +115,7 @@ class TimeWindowFilterSettings:
110115

111116
start: datetime
112117
end: datetime
113-
recurrence: Recurrence
118+
recurrence: Optional[Recurrence]
114119

115120

116121
@dataclass

0 commit comments

Comments
 (0)