Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added the get_epoch_time operation #1303

Open
wants to merge 2 commits into
base: WS_2_0
Choose a base branch
from
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