diff --git a/crc/scripts/get_localtime.py b/crc/scripts/get_localtime.py new file mode 100644 index 00000000..b5c46f0e --- /dev/null +++ b/crc/scripts/get_localtime.py @@ -0,0 +1,19 @@ +from crc.scripts.script import Script +from crc.api.common import ApiError + + +class GetLocaltime(Script): + + def get_description(self): + return """Converts a UTC Datetime object into a Datetime object with a different timezone. + Defaults to US/Eastern""" + + def do_task_validate_only(self, task, study_id, workflow_id, **kwargs): + if len(kwargs): + return True + raise ApiError(code='missing_timestamp', + message='You must include a timestamp to convert.') + + def do_task(self, task, study_id, workflow_id, **kwargs): + pass + diff --git a/tests/data/get_localtime/get_localtime.bpmn b/tests/data/get_localtime/get_localtime.bpmn new file mode 100644 index 00000000..ff8d1d2f --- /dev/null +++ b/tests/data/get_localtime/get_localtime.bpmn @@ -0,0 +1,72 @@ + + + + + Flow_0lnc9x0 + + + + timestamp = email_model.timestamp +localtime = get_localtime(timestamp) + Flow_0gtgzcf + Flow_0k1hbif + + + + # Timestamp +{{ timestamp }} + + +# Localtime +{{ localtime }} + Flow_0k1hbif + Flow_0kgtoh1 + + + + Flow_0kgtoh1 + + + + This is my email + Flow_0lnc9x0 + Flow_0gtgzcf + email_model = email(subject='My Email Subject', recipients='user@example.com') + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/scripts/test_get_localtime.py b/tests/scripts/test_get_localtime.py new file mode 100644 index 00000000..460481fa --- /dev/null +++ b/tests/scripts/test_get_localtime.py @@ -0,0 +1,21 @@ +from tests.base_test import BaseTest +from crc.models.file import FileDataModel +from crc import session + + +class TestGetLocaltime(BaseTest): + + def test_get_localtime(self): + self.load_example_data() + # file_model = session.query(FileDataModel).first() + # test_time = file_model.date_created + + workflow = self.create_workflow('get_localtime') + workflow_api = self.get_workflow_api(workflow) + task = workflow_api.next_task + # workflow_api = self.complete_form(workflow, task, {'timestamp': test_time}) + + # local_time = + + print('test_get_localtime') +