{
  "openapi": "3.1.1",
  "info": {
    "title": "Timeslice Duration \u0026 Time Range Parser API",
    "version": "1.0.0",
    "summary": "Turn 1h30, 90m, 1:30, 9-10:30 or 9am to 1pm into h:mm, decimal hours and ISO 8601.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://timeslicedurationparser.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Turn 1h30, 90m, 1:30, 9-10:30 or 9am to 1pm into h:mm, decimal hours and ISO 8601.",
        "description": "Reads durations and time ranges the way people type them — 1h30, 1 hour 30 minutes, 90m, 1:30, 1,5 h, PT1H30M, 9-10:30, 9am to 1pm, 22:00-02:00, 14:00 + 45m — one per line, and returns each as h:mm, decimal hours and an ISO 8601 duration, with the total and how every line was read.\n\nMethodology:\n- Each line is tried as a time range first (start–end, “to”, “until”, “bis”, or start + duration), then as a duration, then as a single time of day. An end at or before the start means the range ends on the next day.\n- Durations: number + unit tokens (d, h, hr, hour, min, m, s, also German Std/Min) from large to small; a trailing bare number after hours means minutes (1h30); h:mm and h:mm:ss; ISO 8601 PnDTnHnMnS. A bare number up to 10 counts as hours, a larger whole number as minutes.\n- Times: 9, 930, 9:30, 9.30, 9h30, 21h, 9:30 pm, 12 am = 00:00, 12 pm = noon, noon and midnight; 24:00 is the end of the day. A meridiem on the end time also applies to the start when the start has none (9-11am).\n- Decimal hours are rounded to two places for display; totals use exact seconds. Optional rounding applies to each line before the total.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "timeslice_duration_parser",
        "x-owner-app": "timeslice",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TimesliceDurationParserInput"
              },
              "examples": {
                "example1": {
                  "summary": "Mixed ways of writing time",
                  "value": {
                    "lines": "1h30\n90m\n2:15\n1,5 h\n9-10:30\n9am to 1pm\n22:00-02:00\n14:00 + 45m"
                  }
                },
                "example2": {
                  "summary": "A paper time card in 12-hour times",
                  "value": {
                    "lines": "8:30am to 12pm\n12:45pm-5:15pm\n6pm for 1h15",
                    "clock": "12"
                  }
                },
                "example3": {
                  "summary": "Tenths of an hour for billing",
                  "value": {
                    "lines": "17m\n1h04\n2 hours 41 minutes\n0:52",
                    "roundMinutes": "6"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimesliceDurationParserResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "TimesliceDurationParserInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "lines": {
            "title": "Durations or time ranges (one per line)",
            "description": "Durations: 1h30, 1h 30m, 90m, 1:30, 1.5 (a bare number up to 10 is hours, larger whole numbers are minutes), PT1H30M. Ranges: 9-10:30, 9:00–17:30, 9am to 1pm, 14:00 + 45m.",
            "type": "string",
            "maxLength": 20000,
            "default": "1h30\n90m\n2:15\n1,5 h\n9-10:30\n9am to 1pm\n22:00-02:00\n14:00 + 45m"
          },
          "clock": {
            "title": "Show times as",
            "type": "string",
            "enum": [
              "24",
              "12"
            ],
            "default": "24"
          },
          "roundMinutes": {
            "title": "Round each line to",
            "type": "string",
            "enum": [
              "0",
              "5",
              "6",
              "15",
              "30"
            ],
            "default": "0"
          }
        },
        "required": []
      },
      "TimesliceDurationParserResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object"
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}