|
3 | 3 |
|
4 | 4 |
|
5 | 5 | class DateTimeUtils: |
| 6 | + UTC_TIMEZONE = "UTC" |
| 7 | + DST_TIMEZONE = "Europe/London" |
6 | 8 | """ |
7 | 9 | A utility class for doing common actions with datetimes. |
8 | 10 | """ |
@@ -70,55 +72,63 @@ def get_a_day_of_week(date: datetime) -> str: |
70 | 72 | return date.strftime("%A") |
71 | 73 |
|
72 | 74 | @staticmethod |
73 | | - def report_timestamp_date_format() -> str: |
74 | | - # If the bcss timestamp is displaying in UTC, set this to True |
75 | | - # If the bcss timestamp is displaying in DST, set this to False |
76 | | - USE_UTC = True |
| 75 | + def report_timestamp_date_format(use_utc: bool = True) -> str: |
| 76 | + """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. |
| 78 | + """ |
77 | 79 |
|
78 | 80 | """Gets the current datetime in the timestamp format used on the report pages. |
79 | 81 | Based on the value of `USE_UTC`, it chooses the appropriate timezone. |
80 | 82 | """ |
81 | | - if USE_UTC: |
| 83 | + if use_utc: |
82 | 84 | return DateTimeUtils.format_date( |
83 | | - datetime.now(ZoneInfo("UTC")), "%d/%m/%Y at %H:%M:%S" |
| 85 | + datetime.now(ZoneInfo(DateTimeUtils.UTC_TIMEZONE)), |
| 86 | + "%d/%m/%Y at %H:%M:%S", |
84 | 87 | ) |
85 | 88 | else: |
86 | 89 | return DateTimeUtils.format_date( |
87 | | - datetime.now(ZoneInfo("Europe/London")), "%d/%m/%Y at %H:%M:%S" |
| 90 | + datetime.now(ZoneInfo(DateTimeUtils.DST_TIMEZONE)), |
| 91 | + "%d/%m/%Y at %H:%M:%S", |
88 | 92 | ) |
89 | 93 |
|
90 | 94 | @staticmethod |
91 | | - def fobt_kits_logged_but_not_read_report_timestamp_date_format() -> str: |
92 | | - # If the bcss timestamp is displaying in UTC, set this to True |
93 | | - # If the bcss timestamp is displaying in DST, set this to False |
94 | | - USE_UTC = False |
| 95 | + def fobt_kits_logged_but_not_read_report_timestamp_date_format( |
| 96 | + use_utc: bool = False, |
| 97 | + ) -> str: |
| 98 | + """Gets the current datetime in the format used for FOBT Kits Logged but Not Read report. |
| 99 | + Based on the value of `use_utc`, it chooses the appropriate timezone. |
| 100 | + """ |
95 | 101 |
|
96 | 102 | """Gets the current datetime in the format used for FOBT Kits Logged but Not Read report. |
97 | 103 | Based on the value of `USE_UTC`, it chooses the appropriate timezone. |
98 | 104 | """ |
99 | | - if USE_UTC: |
| 105 | + if use_utc: |
100 | 106 | return DateTimeUtils.format_date( |
101 | | - datetime.now(ZoneInfo("UTC")), "%d %b %Y %H:%M:%S" |
| 107 | + datetime.now(ZoneInfo(DateTimeUtils.UTC_TIMEZONE)), "%d %b %Y %H:%M:%S" |
102 | 108 | ) |
103 | 109 | else: |
104 | 110 | return DateTimeUtils.format_date( |
105 | | - datetime.now(ZoneInfo("Europe/London")), "%d %b %Y %H:%M:%S" |
| 111 | + datetime.now(ZoneInfo(DateTimeUtils.DST_TIMEZONE)), "%d %b %Y %H:%M:%S" |
106 | 112 | ) |
107 | 113 |
|
108 | 114 | @staticmethod |
109 | | - def screening_practitioner_appointments_report_timestamp_date_format() -> str: |
110 | | - # If the bcss timestamp is displaying in UTC, set this to True |
111 | | - # If the bcss timestamp is displaying in DST, set this to False |
112 | | - USE_UTC = True |
| 115 | + def screening_practitioner_appointments_report_timestamp_date_format( |
| 116 | + use_utc: bool = True, |
| 117 | + ) -> str: |
| 118 | + """Gets the current datetime in the format used for Screening Practitioner Appointments report. |
| 119 | + Based on the value of `use_utc`, it chooses the appropriate timezone. |
| 120 | + """ |
113 | 121 |
|
114 | 122 | """Gets the current datetime in the format used for Screening Practitioner Appointments report. |
115 | 123 | Based on the value of `USE_UTC`, it chooses the appropriate timezone. |
116 | 124 | """ |
117 | | - if USE_UTC: |
| 125 | + if use_utc: |
118 | 126 | return DateTimeUtils.format_date( |
119 | | - datetime.now(ZoneInfo("UTC")), "%d.%m.%Y at %H:%M:%S" |
| 127 | + datetime.now(ZoneInfo(DateTimeUtils.UTC_TIMEZONE)), |
| 128 | + "%d.%m.%Y at %H:%M:%S", |
120 | 129 | ) |
121 | 130 | else: |
122 | 131 | return DateTimeUtils.format_date( |
123 | | - datetime.now(ZoneInfo("Europe/London")), "%d.%m.%Y at %H:%M:%S" |
| 132 | + datetime.now(ZoneInfo(DateTimeUtils.DST_TIMEZONE)), |
| 133 | + "%d.%m.%Y at %H:%M:%S", |
124 | 134 | ) |
0 commit comments