Logo
  • Home

Tutorials

  • Overview
  • Your first custom-type input
  • GeoJSON
    • GeoJSON Point
    • GeoJSON Feature
  • OGC Bounding Box
  • STAC
    • STAC Catalog
    • STAC Collection
    • STAC Item
  • String formats
    • Datetime
      • CWL example
      • Input example
      • Execute the example
    • URI
  • Experimental
    • Experimental Discovery Inputs
    • Experimental Process Inputs

How-to guides

  • Overview
  • Use an existing schema
  • Define new types

Reference

  • Overview
  • GeoJSON
    • Types
    • Schema details
  • OGC API Processes
    • Types
    • Schema details
  • STAC
    • Types
    • Schema details
  • String formats
    • Types
    • Schema details

Explanation

  • Custom types and their limits
EOAP schemas
  • Tutorials
  • String formats
  • Datetime
  • Edit on eoap/schemas

Datetime¶

CWL example¶

# Copyright 2025 Terradue
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cwlVersion: v1.2
class: CommandLineTool
label: "Echo Datetime string format"
baseCommand: echo
requirements:
  - class: InlineJavascriptRequirement
  - class: SchemaDefRequirement
    types:
      - $import: https://raw.githubusercontent.com/eoap/schemas/main/string_format.yaml
inputs:
  start_time:
    type: https://raw.githubusercontent.com/eoap/schemas/main/string_format.yaml#DateTime
    label: "Start Time"
    doc: "Start time in ISO 8601 format"
    inputBinding:
      valueFrom: |
        ${
          // Parse ISO datetime and extract parts
          var date = new Date(inputs.start_time.value);
          if (isNaN(date.getTime())) {
            throw "Invalid ISO 8601 date format for start_time.";
          }

          var dateParts = [
            "Date Breakdown:",
            "Year: " + date.getUTCFullYear(),
            "Month: " + (date.getUTCMonth() + 1),
            "Day: " + date.getUTCDate(),
            "Hour: " + date.getUTCHours(),
            "Minute: " + date.getUTCMinutes(),
            "Second: " + date.getUTCSeconds()
          ].join("\n * ");

          return dateParts;
        }
outputs:
  echo_output:
    type: stdout
stdout: echo_output.txt

Input example¶

# Copyright 2025 Terradue
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

start_time:
  class: https://raw.githubusercontent.com/eoap/schemas/main/ogc.yaml#DateTime
  value: "2025-06-15T12:34:56Z"

Execute the example¶

Run the example with:

cwltool examples/string-format/datetime.cwl examples/string-format/datetime.yaml

This produces the output:

INFO /opt/hostedtoolcache/Python/3.12.14/x64/bin/cwltool 3.3.20260925135507
INFO Resolved '../../examples/string-format/datetime.cwl' to 'file:///home/runner/work/schemas/schemas/examples/string-format/datetime.cwl'
INFO [job datetime.cwl] /tmp/0woc5trx$ echo \
    'Date Breakdown:
 * Year: 2025
 * Month: 6
 * Day: 15
 * Hour: 12
 * Minute: 34
 * Second: 56' > /tmp/0woc5trx/echo_output.txt
INFO [job datetime.cwl] completed success
INFO Final process status is success

The content of the echo_output.txt file is:

Date Breakdown:
 * Year: 2025
 * Month: 6
 * Day: 15
 * Hour: 12
 * Minute: 34
 * Second: 56
Previous Next

Apache License, Version 2.0

Built with MkDocs using a theme provided by Read the Docs.
eoap/schemas « Previous Next »