|
1 | 1 | from datetime import datetime, timedelta |
2 | | -from zoneinfo import ZoneInfo |
3 | 2 |
|
4 | 3 |
|
5 | 4 | class DateTimeUtils: |
6 | | - UTC_TIMEZONE = "UTC" |
7 | | - DST_TIMEZONE = "Europe/London" |
8 | 5 | """ |
9 | 6 | A utility class for doing common actions with datetimes. |
10 | 7 | """ |
@@ -72,54 +69,31 @@ def get_a_day_of_week(date: datetime) -> str: |
72 | 69 | return date.strftime("%A") |
73 | 70 |
|
74 | 71 | @staticmethod |
75 | | - def report_timestamp_date_format(use_utc: bool = True) -> str: |
| 72 | + def report_timestamp_date_format() -> str: |
76 | 73 | """Gets the current datetime in the timestamp format used on the report pages. |
77 | | - Based on the value of `use_utc`, it chooses the appropriate timezone. |
| 74 | + Returns: |
| 75 | + str: The current date and time in the format 'dd/mm/yyyy at hh:mm:ss'. |
| 76 | + e.g. '24/01/2025 at 12:00:00' |
78 | 77 | """ |
79 | 78 |
|
80 | | - if use_utc: |
81 | | - return DateTimeUtils.format_date( |
82 | | - datetime.now(ZoneInfo(DateTimeUtils.UTC_TIMEZONE)), |
83 | | - "%d/%m/%Y at %H:%M:%S", |
84 | | - ) |
85 | | - else: |
86 | | - return DateTimeUtils.format_date( |
87 | | - datetime.now(ZoneInfo(DateTimeUtils.DST_TIMEZONE)), |
88 | | - "%d/%m/%Y at %H:%M:%S", |
89 | | - ) |
| 79 | + return DateTimeUtils.format_date(datetime.now(), "%d/%m/%Y at %H:%M:%S") |
90 | 80 |
|
91 | 81 | @staticmethod |
92 | | - def fobt_kits_logged_but_not_read_report_timestamp_date_format( |
93 | | - use_utc: bool = False, |
94 | | - ) -> str: |
| 82 | + def fobt_kits_logged_but_not_read_report_timestamp_date_format() -> str: |
95 | 83 | """Gets the current datetime in the format used for FOBT Kits Logged but Not Read report. |
96 | | - Based on the value of `use_utc`, it chooses the appropriate timezone. |
| 84 | + Returns: |
| 85 | + str: The current date and time in the format 'dd MonthName yyyy hh:mm:ss'. |
| 86 | + e.g. '24 Jan 2025 12:00:00' |
97 | 87 | """ |
98 | 88 |
|
99 | | - if use_utc: |
100 | | - return DateTimeUtils.format_date( |
101 | | - datetime.now(ZoneInfo(DateTimeUtils.UTC_TIMEZONE)), "%d %b %Y %H:%M:%S" |
102 | | - ) |
103 | | - else: |
104 | | - return DateTimeUtils.format_date( |
105 | | - datetime.now(ZoneInfo(DateTimeUtils.DST_TIMEZONE)), "%d %b %Y %H:%M:%S" |
106 | | - ) |
| 89 | + return DateTimeUtils.format_date(datetime.now(), "%d %b %Y %H:%M:%S") |
107 | 90 |
|
108 | 91 | @staticmethod |
109 | | - def screening_practitioner_appointments_report_timestamp_date_format( |
110 | | - use_utc: bool = True, |
111 | | - ) -> str: |
112 | | - """Gets the current datetime in the format used for Screening Practitioner Appointments report. |
113 | | - Based on the value of `use_utc`, it chooses the appropriate timezone. |
| 92 | + def screening_practitioner_appointments_report_timestamp_date_format() -> str: |
| 93 | + """Gets the current datetime in the format used for the screening practitioner appointments report. |
| 94 | + Returns: |
| 95 | + str: the current datetime in the format 'dd.mm.yyyy at hh:mm:ss' |
| 96 | + e.g. '24.01.2025 at 12:00:00' |
114 | 97 | """ |
115 | 98 |
|
116 | | - if use_utc: |
117 | | - return DateTimeUtils.format_date( |
118 | | - datetime.now(ZoneInfo(DateTimeUtils.UTC_TIMEZONE)), |
119 | | - "%d.%m.%Y at %H:%M:%S", |
120 | | - ) |
121 | | - else: |
122 | | - return DateTimeUtils.format_date( |
123 | | - datetime.now(ZoneInfo(DateTimeUtils.DST_TIMEZONE)), |
124 | | - "%d.%m.%Y at %H:%M:%S", |
125 | | - ) |
| 99 | + return DateTimeUtils.format_date(datetime.now(), "%d.%m.%Y at %H:%M:%S") |
0 commit comments