Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions content/io/cloudslang/base/datetime/get_epoch_time.sl
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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