Skip to content

JQ pScheduler Library

Mark Feit edited this page Aug 8, 2017 · 3 revisions

This page describes

iso8601 - Conversion of ISO 8601 Values

duration_as_seconds(value)

Calculates the number of seconds in an ISO 8601 duration.

Parameters

value - A string containing an ISO 8601 duration (e.g., P1W3DT9H).

Return Value

An integer (e.g., 896400).

Example

import "pscheduler/iso8601" as iso; iso::duration_as_seconds("PT1H2M3S") -> 3723

timestamp_parsed(timestamp)

Parses an ISO8601 timestamp into its component parts.

Parameters

timestamp - A string containing a valid ISO 8601 timestamp.

Return Value

A JSON object containing the following pairs:

  • year, month, day - The date.
  • hour, minute, second - If provided, the time of day.
  • offset_hr, offset_min - If provided, the offset from UTC represented by the time in hours and minutes.

Example

import "pscheduler/iso8601" as iso; iso::timestamp_parsed("2017-05-04T02:15:18-04:00")
  -> {
         "year": "2017",
         "month": "05",
         "day": "04",
         "hour": "02",
         "minute": "15",
         "second": "18",
         "offset_hr": "-04",
         "offset_min": "00"
    }

si - Conversion of numbers in SI units

as_integer(value)

Converts a number or string containing a number and a [SI whole-unit prefix] https://www.nist.gov/pml/weights-and-measures/prefixes) to an integer value.

Parameters

value - A string containing the value to be converted (e.g., 500k, 16Mi or 22030).

Return Value

An integer (e.g., 896400).

Examples

import "pscheduler/si" as si; si::as_integer("12ki") -> 12288

import "pscheduler/si" as si; si::as_integer("12.34M") -> 12340000

import "pscheduler/si" as si; si::as_integer(8675309) -> 8675309