L2 Hub
Pontus
formatter
Get Current Time

L2 Construct: get_current_time

formatters current_time

Description

GetCurrentTime returns the current time in a specified timezone and format.

This function retrieves the current time based on the specified timezone and returns it in the desired format.

Input:

  • Timezone: Optional. The timezone to use for calculations. Defaults to UTC if not provided.
  • Format: Required. The desired output format for the time string.

Output:

  • Time: The formatted time string.
  • UnixTime: The Unix timestamp for the current time.

The function handles timezone conversions and supports various predefined time formats.

L2 Data

  1. Provider: pontus
  2. Module: formatter
  3. Action: get_current_time

Example Step

{
  "name": "insert-your-step-name",
  "type": "l2",
  "l2_data": {
    "provider": "pontus",
    "module": "formatter",
    "action": "get_current_time",
    "metadata": {}
  }
}
 

Input

Example

{
  "timezone": "UTC",
  "format": "YYYY-MM-DD"
}
 

Schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://pontus.bpa/pkgs/l2/pontus/formatters/get-current-time-input",
  "$ref": "#/$defs/GetCurrentTimeInput",
  "$defs": {
    "GetCurrentTimeInput": {
      "properties": {
        "timezone": {
          "type": "string"
        },
        "format": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": ["format"]
    }
  }
}
 

Output

Example

{
  "time": "2024-05-01",
  "unix_time": 1714406400,
  "error": {
    "is_error": false
  }
}
 

Schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://pontus.bpa/pkgs/l2/pontus/formatters/get-current-time-output",
  "$ref": "#/$defs/GetCurrentTimeOutput",
  "$defs": {
    "GetCurrentTimeOutput": {
      "properties": {
        "time": {
          "type": "string"
        },
        "unix_time": {
          "type": "integer"
        },
        "error": {
          "$ref": "#/$defs/HandlerError"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": ["time", "unix_time", "error"]
    },
    "HandlerError": {
      "properties": {
        "is_error": {
          "type": "boolean"
        },
        "errors": {
          "items": {
            "type": "string"
          },
          "type": "array"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": ["is_error"]
    }
  }
}