SpecFormula AI
ISABackendSymbol System

TIME-System

Time expression parsing

TIME-System provides three functions that convert declarative time expressions into type-safe time objects.

Three Functions

FunctionPurposeJava TypeC# Type
@time(expr)Full datetimeZonedDateTimeDateTimeOffset
@date(expr)Date onlyLocalDateDateOnly
@localtime(expr)Time onlyLocalTimeTimeOnly

Absolute Time

# ISO 8601 format
@time("2025-11-04T08:00:00")
@time("2025-11-04T08:00:00+08:00")
@time("2025-11-04T08:00:00Z")

# Date only (defaults to 00:00:00)
@time("2025-11-04")

# Date function
@date("2025-11-04")
@date("2025/12/16")

# Time function
@localtime("21:00")
@localtime("21:00:30")

Relative Time

Calculated based on current (or mock) time:

@time("now")         # Current time
@time("now-1d")      # Yesterday
@time("now+1h")      # One hour later
@time("now-1M-1d")   # One month and one day ago

Time Units

UnitSymbolExample
Secondss (lowercase)now-30s
Minutesm (lowercase)now+5m
Hoursh (lowercase)now-2h
Daysd (lowercase)now+7d
MonthsM (uppercase)now-1M

With Mock Time

When mock time is set via TimeControl, now uses the mock time:

Given current time is "2026-02-01T10:00:00"
When create log, call table:
  | logTime       |
  | @time("now-1d") |    # → 2026-01-31T10:00:00

Timezone Handling

Input FormatTimezone Behavior
2025-11-04T08:00:00+08:00Uses specified timezone
2025-11-04T08:00:00ZUses UTC
2025-11-04T08:00:00Uses system default timezone

Type Safety

TIME-System returns the correct time type, not strings:

# ❌ Plain string, no type guarantee
| eventTime           |
| 2025-11-04T08:00:00 |

# ✅ Returns ZonedDateTime, correct type
| eventTime                    |
| @time("2025-11-04T08:00:00") |

Usage Restrictions

TIME-System cannot be used directly with VAR extraction keys:

# ❌ Not supported
| >eventTime                   |
| @time("2026-01-15T09:00:00") |

# ✅ Correct: extract from execution result
| >eventTime |
| <createdAt |

Error Handling

Throws a clear exception on parse failure:

Unable to parse time expression: @time("invalid").
Supported formats: ISO 8601 (2025-11-04T08:00:00), date (2025-11-04), relative time (now, now-1d)

Complete Example

Feature: Time Expressions

  Background:
    Given current time is "2026-01-27T10:00:00"

  Example: Using various time expressions
    # Absolute time
    Given prepare an event, with table:
      | name    | startTime                    |
      | Meeting | @time("2026-01-28T14:00:00") |

    # Relative time
    Given prepare a task, with table:
      | name   | dueDate        |
      | Report | @time("now+7d")  |

    # Date only
    Given prepare a user, with table:
      | name  | birthday            |
      | Alice | @date("2000-01-15") |

On this page