Skip to main content

DateTime & Testing

Endpoints for testing datetime functionality and time selection features.

DateTime Testing

POST /api/test-datetime

Tests datetime selection functionality.

Request Body:

{
"action": "select_datetime",
"date": "2024-01-15",
"time": "14:30",
"timezone": "America/New_York"
}

Response:

{
"success": true,
"selectedDateTime": "2024-01-15T14:30:00.000-05:00",
"formatted": "January 15, 2024 at 2:30 PM EST",
"timestamp": 1705349400000,
"variables": {
"selectedDate": "2024-01-15",
"selectedTime": "14:30",
"selectedTimestamp": 1705349400000
}
}

POST /api/test-time

Tests time selection functionality.

Request Body:

{
"action": "select_time",
"time": "09:15",
"format": "12h"
}

Response:

{
"success": true,
"selectedTime": "09:15",
"formatted12h": "9:15 AM",
"formatted24h": "09:15",
"timestamp": 33300000, // milliseconds since midnight
"variables": {
"selectedTime": "09:15",
"selectedHours": 9,
"selectedMinutes": 15
}
}

POST /api/test-relative-time

Tests relative time selection functionality.

Request Body:

{
"action": "select_relative_time",
"hours": 2,
"minutes": 30,
"relativeTo": "now"
}

Response:

{
"success": true,
"relativeTime": {
"hours": 2,
"minutes": 30,
"totalMinutes": 150
},
"calculatedTime": "2024-01-01T14:30:00.000Z",
"formatted": "2 hours 30 minutes from now",
"timestamp": 1704120600000,
"variables": {
"lastSelectedTime": "2:30 PM",
"lastSelectedHours": 2,
"lastSelectedMinutes": 30
}
}

Time Selection Features

Absolute Time Selection

Selects a specific time of day:

{
"action": "select_time",
"time": "14:30",
"format": "24h"
}

Relative Time Selection

Selects time relative to current time:

{
"action": "select_relative_time",
"hours": 4,
"minutes": 0
}

DateTime Combination

Combines date and time selection:

{
"action": "select_datetime",
"date": "2024-12-25",
"time": "00:00",
"timezone": "UTC"
}

Variable Storage

All time selection actions automatically store variables for use in subsequent flow steps:

Time Variables

  • lastSelectedTime: Formatted time string (e.g., "2:30 PM")
  • lastSelectedHours: Numeric hours value
  • lastSelectedMinutes: Numeric minutes value

DateTime Variables

  • selectedDate: Selected date string (YYYY-MM-DD)
  • selectedTime: Selected time string (HH:MM)
  • selectedTimestamp: Unix timestamp in milliseconds

Usage in Validation Steps

Reference stored variables using ${variableName} syntax:

{
"action": "check_screen",
"targetElement": "Verify time is set to ${lastSelectedTime}",
"confidence": 0.8
}

Testing Examples

Test Time Selection

curl -X POST http://localhost:3001/api/test-time \
-H "Content-Type: application/json" \
-d '{
"action": "select_time",
"time": "15:45",
"format": "24h"
}'

Test Relative Time

curl -X POST http://localhost:3001/api/test-relative-time \
-H "Content-Type: application/json" \
-d '{
"action": "select_relative_time",
"hours": 1,
"minutes": 30
}'

Test DateTime Selection

curl -X POST http://localhost:3001/api/test-datetime \
-H "Content-Type: application/json" \
-d '{
"action": "select_datetime",
"date": "2024-03-15",
"time": "10:00",
"timezone": "America/Los_Angeles"
}'

Supported Timezones

The system supports all IANA timezone identifiers:

  • America/New_York
  • Europe/London
  • Asia/Tokyo
  • Australia/Sydney
  • UTC
  • Etc/GMT+5
  • And many more...

Time Format Options

12-Hour Format

{
"time": "2:30 PM",
"format": "12h"
}

24-Hour Format

{
"time": "14:30",
"format": "24h"
}

Flexible Parsing

The system accepts various time formats:

  • "2:30 PM"
  • "14:30"
  • "2:30PM"
  • "1430"

Validation and Error Handling

Input Validation

  • Time values must be valid (00:00-23:59)
  • Date values must be valid calendar dates
  • Timezone identifiers must be recognized IANA codes

Error Responses

{
"success": false,
"error": "Invalid time format",
"details": "Time must be in HH:MM format",
"suggestion": "Use format like '14:30' or '2:30 PM'"
}

Edge Cases Handled

  • Midnight: "00:00" or "12:00 AM"
  • Noon: "12:00" or "12:00 PM"
  • Single digit hours: "9:30""09:30"
  • Timezone conversions and DST handling
  • Leap year date validation

Integration with Flow Variables

Time selection actions integrate seamlessly with the flow variable system:

{
"sequence": [
{
"action": "select_relative_time",
"parameters": {
"hours": 2,
"minutes": 15
}
},
{
"action": "type",
"text": "Meeting scheduled for ${lastSelectedTime}",
"targetElement": "notes_field"
},
{
"action": "check_screen",
"targetElement": "Confirm time shows ${lastSelectedHours}:${lastSelectedMinutes}"
}
]
}

Best Practices

Time Selection

  • Use consistent formats within flows
  • Validate time selections in subsequent steps
  • Consider timezone implications for distributed teams
  • Test with different time formats for robustness

Variable Usage

  • Use descriptive variable names when possible
  • Clear variables between unrelated time selections
  • Validate variable existence before using in expressions
  • Consider time format conversions for display

Testing

  • Test with various time formats and edge cases
  • Verify timezone handling across different regions
  • Test variable persistence across flow steps
  • Validate time calculations and relative time selection