From a2b75a78d780ba37680a2e9ab2bc12046ce16949 Mon Sep 17 00:00:00 2001 From: "christopher.tubbs" Date: Thu, 20 Jul 2023 10:44:05 -0500 Subject: [PATCH] Updated the _generate_evaluation_id function to take in an optional datetime for testing purposes, consider server timezone (rather than utc in order to reduce cognitive time computation), and apply the timezone to the end of the of the generated string as suggested. --- python/gui/MaaS/cbv/evaluation.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/python/gui/MaaS/cbv/evaluation.py b/python/gui/MaaS/cbv/evaluation.py index 5640905b1..ba3c5b30e 100644 --- a/python/gui/MaaS/cbv/evaluation.py +++ b/python/gui/MaaS/cbv/evaluation.py @@ -34,9 +34,13 @@ def get(self, request: HttpRequest) -> HttpResponse: return render(request, template_name=self.template, context=context) -def _generate_evaluation_id() -> str: - current_date = datetime.now() - date_representation = current_date.strftime("%m-%d_%H.%M") +def _generate_evaluation_id(generation_date: datetime = None) -> str: + current_date = generation_date or datetime.now() + + if current_date.tzinfo is None: + current_date = current_date.astimezone() + + date_representation = current_date.strftime("%m-%d_%H.%M%z") evaluation_id = f"manual_evaluation_at_{date_representation}" return evaluation_id