跳转至

Parse duration(解析持续时间(Parse duration))

Supported in: Batch

Parses an ISO8601 string duration and start time to its length in a specific time unit.

Expression categories: Datetime, String

Declared arguments

  • Duration: The ISO8601 duration to parse. If invalid, the output will be null.
    Expression\
  • Start time: Start timestamp of duration, used for determining the length of certain durations (e.g. months).
    Expression\
  • Unit: Output time unit. The result will be the number of complete time units represented by the duration.
    Enum\

Output type: Long

Examples

Example 1: Base case

Argument values:

  • Duration: PT1M30.5S
  • Start time: 2022-10-01T09:00:00Z
  • Unit: SECONDS

Output: 90


Example 2: Base case

Argument values:

  • Duration: P2DT6H
  • Start time: 2022-10-01T09:00:00Z
  • Unit: HOURS

Output: 54


Example 3: Base case

Argument values:

  • Duration: P1M2W
  • Start time: 2023-02-01T09:00:00Z
  • Unit: DAYS

Output: 42


Example 4: Null case

Argument values:

  • Duration: PT1Y6M
  • Start time: 2022-02-01T00:00:00Z
  • Unit: YEARS

Output: null


Example 5: Null case

Argument values:

  • Duration: null
  • Start time: 2022-02-01T00:00:00Z
  • Unit: MILLISECONDS

Output: null


Example 6: Edge case

Argument values:

  • Duration: P300000000000Y
  • Start time: 2022-02-01T00:00:00Z
  • Unit: MILLISECONDS

Output: null



中文翻译


解析持续时间(Parse duration)

支持:批处理(Batch)

将 ISO8601 格式的持续时间字符串与起始时间解析为特定时间单位的长度。

表达式类别: 日期时间(Datetime)、字符串(String)

声明的参数

  • 持续时间(Duration): 要解析的 ISO8601 持续时间。如果无效,输出结果将为 null。
    表达式\
  • 起始时间(Start time): 持续时间的起始时间戳,用于确定某些持续时间(如月份)的长度。
    表达式\
  • 单位(Unit): 输出的时间单位。结果将表示该持续时间所包含的完整时间单位数量。
    枚举\

输出类型: Long

示例

示例 1:基本情况

参数值:

  • 持续时间: PT1M30.5S
  • 起始时间: 2022-10-01T09:00:00Z
  • 单位: SECONDS

输出: 90


示例 2:基本情况

参数值:

  • 持续时间: P2DT6H
  • 起始时间: 2022-10-01T09:00:00Z
  • 单位: HOURS

输出: 54


示例 3:基本情况

参数值:

  • 持续时间: P1M2W
  • 起始时间: 2023-02-01T09:00:00Z
  • 单位: DAYS

输出: 42


示例 4:空值情况

参数值:

  • 持续时间: PT1Y6M
  • 起始时间: 2022-02-01T00:00:00Z
  • 单位: YEARS

输出: null


示例 5:空值情况

参数值:

  • 持续时间: null
  • 起始时间: 2022-02-01T00:00:00Z
  • 单位: MILLISECONDS

输出: null


示例 6:边界情况

参数值:

  • 持续时间: P300000000000Y
  • 起始时间: 2022-02-01T00:00:00Z
  • 单位: MILLISECONDS

输出: null