Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AGenUI AGenUI FormatDateFunctionCall

From Leeroopedia
Knowledge Sources
Domains Parsing, Date_Time_Formatting
Last Updated 2026-10-24 17:21 GMT

Overview

Built-in function call that formats a date or timestamp into a human-readable string using a TR35 pattern, provided by the AGenUI C++ core.

Description

The `FormatDateFunctionCall` is a C++ built-in function (subclass of `IFunctionCall`) registered automatically during `SurfaceCoordinator::initFunctionCalls()`. It accepts a `value` (ISO 8601 string or Unix timestamp in milliseconds) and a `format` string containing TR35 date pattern tokens, and returns the formatted date string.

The TR35 pattern parser supports the following tokens with repeat-count semantics:

Token Count Output
y 2 2-digit year (e.g. "24")
y 3+ Full year (e.g. "2024")
M 1 Numeric month (e.g. "3")
M 2 Zero-padded month (e.g. "03")
M 3 Abbreviated month name (e.g. "Mar")
M 4+ Full month name (e.g. "March")
d 1 Numeric day (e.g. "5")
d 2+ Zero-padded day (e.g. "05")
E 1-3 Abbreviated weekday (e.g. "Mon")
E 4+ Full weekday (e.g. "Monday")
H 1 24-hour clock (e.g. "9")
H 2+ Zero-padded 24-hour (e.g. "09")
h 1 12-hour clock (e.g. "9")
h 2+ Zero-padded 12-hour (e.g. "09")
m 1+ Zero-padded minutes (e.g. "05")
s 1+ Zero-padded seconds (e.g. "07")
a 1+ AM/PM marker

Any non-token characters in the format string are emitted literally.

Usage

  • In A2UI protocol: use `{"call": "formatDate", "args": {"value": "<date>", "format": "<pattern>"}}` in any attribute or action.
  • Auto-registered: no host action needed; registered with 14 other builtins during `SurfaceCoordinator` construction.
  • Value formats: ISO 8601 string (`"2024-03-15T14:30:00Z"`) or Unix timestamp in milliseconds (number).

Code Reference

Source Location

Signature

// core/src/function_call/builtins/agenui_format_date_functioncall.h
namespace agenui {

class FormatDateFunctionCall : public IFunctionCall {
public:
    /// Execute the date formatting function
    /// @param args JSON with "value" (string ISO 8601 or number ms) and "format" (TR35 pattern)
    /// @return Resolution with formatted string on success, or error
    FunctionCallResolution execute(const nlohmann::json& args) override;

    /// Returns config: name="formatDate", returnType="string"
    FunctionCallConfig getConfig() const override;
};

} // namespace agenui

Import

#include "function_call/builtins/agenui_format_date_functioncall.h"

I/O Contract

Inputs

Name Type Required Description
args["value"] `string` or `number` Yes ISO 8601 date string (e.g. "2024-03-15T14:30:00Z") or Unix timestamp in milliseconds
args["format"] `string` Yes TR35 date pattern (e.g. "yyyy-MM-dd HH:mm:ss")

Outputs

Name Type Description
execute returns `FunctionCallResolution` Success with formatted string value, or Error with message
getConfig returns `FunctionCallConfig` name="formatDate", description="Formats a timestamp into a string using a pattern.", returnType="string"

Usage Examples

Using formatDate in A2UI Protocol

{
    "component": "Text",
    "id": "dateLabel",
    "text": {
        "call": "formatDate",
        "args": {
            "value": "2024-03-15T14:30:00Z",
            "format": "yyyy-MM-dd HH:mm:ss"
        }
    }
}

Result: `"2024-03-15 14:30:00"`

Using with Unix Timestamp

{
    "call": "formatDate",
    "args": {
        "value": 1710518400000,
        "format": "EEE, MMM d, yyyy"
    }
}

Result: `"Fri, Mar 15, 2024"`

Using with 12-Hour Clock and AM/PM

{
    "call": "formatDate",
    "args": {
        "value": "2024-03-15T14:30:00Z",
        "format": "MMMM d, yyyy h:mm a"
    }
}

Result: `"March 15, 2024 2:30 PM"`

Related Pages

Implements Principle

Requires Environment

Related Implementations

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment