Coverage for kwai/core/domain/value_objects/weekday.py: 100%
13 statements
« prev ^ index » next coverage.py v7.3.0, created at 2023-09-05 17:55 +0000
« prev ^ index » next coverage.py v7.3.0, created at 2023-09-05 17:55 +0000
1"""Module for defining a value object for a weekday."""
3from datetime import datetime
4from enum import Enum
7class Weekday(Enum):
8 """Represent a day in the week."""
10 MONDAY = 1
11 TUESDAY = 2
12 WEDNESDAY = 3
13 THURSDAY = 4
14 FRIDAY = 5
15 SATURDAY = 6
16 SUNDAY = 7
18 @classmethod
19 def create_from_date(cls, date: datetime) -> "Weekday":
20 """Create a Weekday from a date.
22 Args:
23 date: The date to extract the weekday from.
24 """
25 return Weekday(date.weekday() + 1)