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

1"""Module for defining a value object for a weekday.""" 

2 

3from datetime import datetime 

4from enum import Enum 

5 

6 

7class Weekday(Enum): 

8 """Represent a day in the week.""" 

9 

10 MONDAY = 1 

11 TUESDAY = 2 

12 WEDNESDAY = 3 

13 THURSDAY = 4 

14 FRIDAY = 5 

15 SATURDAY = 6 

16 SUNDAY = 7 

17 

18 @classmethod 

19 def create_from_date(cls, date: datetime) -> "Weekday": 

20 """Create a Weekday from a date. 

21 

22 Args: 

23 date: The date to extract the weekday from. 

24 """ 

25 return Weekday(date.weekday() + 1)