diff --git a/content/io/cloudslang/base/datetime/get_epoch_time.sl b/content/io/cloudslang/base/datetime/get_epoch_time.sl new file mode 100644 index 0000000000..d3a0142c92 --- /dev/null +++ b/content/io/cloudslang/base/datetime/get_epoch_time.sl @@ -0,0 +1,29 @@ +######################################################################################################################## +#!! +#! @description: Checks the current date and time, and returns its representation as an Epoch (Unix) timestamp. +#! +#! @output return_result: Current date and time in timestamp format. +#! @output return_code: 0 for success and 1 for failure. +#! +#! @result SUCCESS: Date/time retrieved successfully. +#! @result FAILURE: Date/time could not be retrieved. +#!!# +######################################################################################################################## +namespace: io.cloudslang.base.datetime +operation: + name: get_epoch_time + python_action: + script: |- + import time + try: + return_result = str(int(time.time())) + return_code = '0' + except: + return_result = sys.exc_info() + return_code = '1' + outputs: + - return_result + - return_code + results: + - SUCCESS: ${return_code == '0'} + - FAILURE diff --git a/test/io/cloudslang/base/datetime/test_get_epoch_time_inputs.yaml b/test/io/cloudslang/base/datetime/test_get_epoch_time_inputs.yaml new file mode 100644 index 0000000000..dcfe149f51 --- /dev/null +++ b/test/io/cloudslang/base/datetime/test_get_epoch_time_inputs.yaml @@ -0,0 +1,7 @@ +successTestGetEpochTime: + description: A successful test for get_epoch_time + testFlowPath: io.cloudslang.base.datetime.get_epoch_time + testSuites: [datetime-local] + outputs: + - return_code: '0' + result: SUCCESS \ No newline at end of file