11from datetime import datetime , timedelta
2+ from typing import Optional
23import random
34
45
@@ -46,27 +47,18 @@ def add_days(date: datetime, days: float) -> datetime:
4647 return date + timedelta (days = days )
4748
4849 @staticmethod
49- def get_day_of_week_for_today (date : datetime ) -> str :
50- """Gets the day of the week (e.g., Monday, Tuesday) from the specified date.
51-
52- Args:
53- date (datetime): The current date using the now function
54-
55- Returns:
56- str: The day of the week relating to the specified date.
50+ def get_day_of_week (date : Optional [datetime ] = None ) -> str :
5751 """
58- return date .strftime ("%A" )
59-
60- @staticmethod
61- def get_a_day_of_week (date : datetime ) -> str :
62- """Gets the day of the week (e.g., Monday, Tuesday) from the specified date.
52+ Returns the day of the week (e.g., Monday, Tuesday) for the given date.
53+ If no date is provided, uses today’s date.
6354
6455 Args:
65- date (datetime): The date for which the day of the week will be returned .
56+ date (Optional[ datetime] ): The date to inspect. Defaults to now .
6657
6758 Returns:
68- str: The day of the week relating to the specified date.
59+ str: Day of week corresponding to the date.
6960 """
61+ date = date or datetime .now ()
7062 return date .strftime ("%A" )
7163
7264 @staticmethod
@@ -99,7 +91,8 @@ def screening_practitioner_appointments_report_timestamp_date_format() -> str:
9991
10092 return DateTimeUtils .format_date (datetime .now (), "%d.%m.%Y at %H:%M:%S" )
10193
102- def month_string_to_number (self , string : str ) -> int :
94+ @staticmethod
95+ def month_string_to_number (string : str ) -> int :
10396 """
10497 This is used to convert a month from a string to an integer.
10598 It accepts the full month or the short version and is not case sensitive
@@ -124,22 +117,17 @@ def month_string_to_number(self, string: str) -> int:
124117 out = months [month_short ]
125118 return out
126119 except Exception :
127- raise ValueError ("Not a month" )
120+ raise ValueError (
121+ f"'{ string } ' is not a valid month name. Accepted values are: { ', ' .join (months .keys ())} "
122+ )
128123
129- def generate_unique_weekday_date (self , start_year : int = 2025 ) -> str :
124+ @staticmethod
125+ def generate_unique_weekday_date (start_year : int = 2025 ) -> str :
130126 """
131- Generates a future weekday date from the specified year onward.
132-
133- This function returns a dynamically generated date string in the format 'dd/mm/yyyy'
134- that always falls on a weekday (Monday–Friday) and is suitable for use in automated tests
135- where the date must differ on each run to avoid duplication issues.
136-
137- A small pseudorandom offset is added to ensure uniqueness between runs.
127+ Returns a random future weekday (Mon–Fri) date from the given year onward.
138128
139- Note:
140- This function uses Python's built-in `random` module to add variability.
141- Since this is for test-only purposes and does not involve security-sensitive logic,
142- the use of a non-cryptographic PRNG is appropriate and intentional.
129+ The result is in 'dd/mm/yyyy' format and useful for automated tests needing
130+ unique, non-weekend dates. Uses non-cryptographic randomness for variability between runs.
143131
144132 Args:
145133 start_year (int): The minimum year from which the date may be generated. Defaults to 2025.
0 commit comments