Skip to content

Utilities

Datetime operations, delay, MD5 hash, and random utilities.

9 modules

ModuleDescription
加上時間在日期時間加上時間
格式化日期時間將日期時間格式化為字串
解析日期時間將字串解析為日期時間
減去時間從日期時間減去時間
目前日期/時間取得目前日期和時間
延遲/暫停暫停工作流程執行指定的時間
MD5 雜湊計算文字的 MD5 雜湊
隨機數字在範圍內產生隨機數字
隨機字串產生隨機字串或 UUID

Modules

加上時間

datetime.add

在日期時間加上時間

Parameters:

NameTypeRequiredDefaultDescription
datetimestringNonowEnter "now" for current time, or ISO 8601 format (e.g., 2024-01-30T14:30:00)
daysnumberNo0Number of days to add (positive) or subtract (negative)
hoursnumberNo0Number of hours to add (positive) or subtract (negative)
minutesnumberNo0Number of minutes to add (positive) or subtract (negative)
secondsnumberNo0Number of seconds to add (positive) or subtract (negative)

Output:

FieldTypeDescription
resultstring結果日期時間
timestampnumberUnix 時間戳記

Example: Add 7 days

yaml
datetime: now
days: 7

Example: Add 2 hours 30 minutes

yaml
datetime: 2024-01-15T10:00:00
hours: 2
minutes: 30

格式化日期時間

datetime.format

將日期時間格式化為字串

Parameters:

NameTypeRequiredDefaultDescription
datetimestringNonowEnter "now" for current time, or ISO 8601 format (e.g., 2024-01-30T14:30:00)
formatselect (%Y-%m-%d, %Y-%m-%d %H:%M:%S, %Y/%m/%d, %d/%m/%Y, %m/%d/%Y, %Y年%m月%d日, %B %d, %Y, %d %b %Y, %H:%M:%S, %H:%M, %I:%M %p, %Y%m%d, %Y-%m-%dT%H:%M:%SZ, %a, %d %b %Y %H:%M:%S)No%Y-%m-%d %H:%M:%SSelect a format or enter custom strftime pattern

Output:

FieldTypeDescription
resultstring格式化後的字串
timestampnumberUnix 時間戳記

Example: Format current time

yaml
datetime: now
format: %Y-%m-%d %H:%M:%S

Example: Custom date format

yaml
datetime: 2024-01-15T10:30:00
format: %B %d, %Y

解析日期時間

datetime.parse

將字串解析為日期時間

Parameters:

NameTypeRequiredDefaultDescription
datetime_stringstringYes-DateTime string to parse (ISO 8601 format recommended)
formatselect (%Y-%m-%d, %Y-%m-%d %H:%M:%S, %Y/%m/%d, %d/%m/%Y, %m/%d/%Y, %Y年%m月%d日, %B %d, %Y, %d %b %Y, %H:%M:%S, %H:%M, %I:%M %p, %Y%m%d, %Y-%m-%dT%H:%M:%SZ, %a, %d %b %Y %H:%M:%S)No%Y-%m-%d %H:%M:%SSelect a format or enter custom strftime pattern

Output:

FieldTypeDescription
resultstring解析結果
timestampnumberUnix 時間戳記
yearnumber
monthnumber
daynumber
hournumber
minutenumber
secondnumber

Example: Parse ISO format

yaml
datetime_string: 2024-01-15T10:30:00

Example: Parse custom format

yaml
datetime_string: January 15, 2024
format: %B %d, %Y

減去時間

datetime.subtract

從日期時間減去時間

Parameters:

NameTypeRequiredDefaultDescription
datetimestringNonowEnter "now" for current time, or ISO 8601 format (e.g., 2024-01-30T14:30:00)
daysnumberNo0Number of days to add (positive) or subtract (negative)
hoursnumberNo0Number of hours to add (positive) or subtract (negative)
minutesnumberNo0Number of minutes to add (positive) or subtract (negative)
secondsnumberNo0Number of seconds to add (positive) or subtract (negative)

Output:

FieldTypeDescription
resultstring結果日期時間
timestampnumberUnix 時間戳記

Example: Subtract 7 days

yaml
datetime: now
days: 7

Example: Subtract 1 hour

yaml
datetime: 2024-01-15T10:00:00
hours: 1

目前日期/時間

utility.datetime.now

取得目前日期和時間

Parameters:

NameTypeRequiredDefaultDescription
formatselect (iso, unix, unix_ms, date, time, custom)Noiso輸出格式
custom_formatstringNo-Python strftime 格式(當 format=custom 時)
timezonestringNoUTC時區(預設:UTC)

Output:

FieldTypeDescription
statusstring操作狀態
datetimestring日期時間物件
timestampnumberUnix 時間戳記(毫秒)
isostringISO 格式日期時間

Example: Example

yaml
format: iso

Example: Example

yaml
format: unix

延遲/暫停

utility.delay

暫停工作流程執行指定的時間

Parameters:

NameTypeRequiredDefaultDescription
duration_msnumberNo1000等待時間(毫秒)
duration_secondsnumberNo-替代方案:以秒為單位的時間

Output:

FieldTypeDescription
statusstring操作狀態
waited_msnumber實際等待時間(毫秒)

Example: Example

yaml
duration_seconds: 2

Example: Example

yaml
duration_ms: 500

MD5 雜湊

utility.hash.md5

計算文字的 MD5 雜湊

Parameters:

NameTypeRequiredDefaultDescription
texttextYes-要雜湊的文字
encodingstringNoutf-8文字編碼

Output:

FieldTypeDescription
statusstring操作狀態
hashstring雜湊值

Example: Example

yaml
text: Hello World

隨機數字

utility.random.number

在範圍內產生隨機數字

Parameters:

NameTypeRequiredDefaultDescription
minnumberNo0最小值(含)
maxnumberNo100最大值(含)
decimalsnumberNo0小數位數(0 表示整數)

Output:

FieldTypeDescription
statusstring操作狀態
valuenumber產生的數值

Example: Example

yaml
min: 1
max: 100
decimals: 0

Example: Example

yaml
min: 0
max: 1
decimals: 2

隨機字串

utility.random.string

產生隨機字串或 UUID

Parameters:

NameTypeRequiredDefaultDescription
lengthnumberNo16字串長度
charsetselect (alphanumeric, letters, lowercase, uppercase, numbers, hex, uuid)Noalphanumeric字元集

Output:

FieldTypeDescription
statusstring操作狀態
valuestring產生的字串

Example: Example

yaml
length: 16
charset: alphanumeric

Example: Example

yaml
charset: uuid

Released under the Apache 2.0 License.