datetime tools #96
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
PRD:
datetime_mathanddatetime_formatOverview
Add two deterministic utility tools for date/time handling:
datetime_math: perform date/time calculations and timezone conversionsdatetime_format: format a normalized timestamp for user-facing outputThese tools must be:
They are intended for tool-calling flows where the model needs exact time reasoning without guessing.
Tool 1:
datetime_mathGoal
Provide exact date/time calculations for the model, including differences, shifting, weekday detection, and timezone conversion.
Non-Goals
This tool must not:
Supported Operations
1.
diffCompute the difference between two timestamps.
Example use cases:
2.
shiftShift a timestamp by a structured duration.
Example use cases:
3.
weekdayReturn the weekday for a timestamp.
Example use cases:
4.
convert_timezoneConvert a timestamp to another timezone without changing the instant.
Example use cases:
Input Contract
Input must be JSON with:
operation(required): one ofdiff,shift,weekday,convert_timezonetimestamp(required forshift,weekday,convert_timezone): RFC3339 timestampleftandright(required fordiff): RFC3339 timestampstarget_timezone(required forconvert_timezone): IANA timezone nameshift):yearsmonthsdayshoursminutessecondsOutput Contract
Output must be compact JSON.
diffoutputshiftoutputweekdayoutputconvert_timezoneoutputValidation Rules
target_timezonemust be a valid IANA timezone.operationmust be recognized.shiftmust reject requests with no shift fields at all.Error Contract
Errors must be structured and compact:
Recommended error codes:
invalid_operationinvalid_timestampinvalid_timezonemissing_required_fieldempty_shiftinternal_errorBehavior Notes
time.Timeandtime.Location.shift, use calendar-aware shifting for years/months/days, not raw second math.diff, return signed difference (sign = -1, 0, 1).Implementation Notes (Go)
internal/tools/datetimefunc ExecuteDatetimeMath(ctx context.Context, input DatetimeMathInput) (DatetimeMathOutput, error)Testing Requirements
Add table-driven tests for:
diffpositive and negative resultsshiftwith mixed unitsweekdayAcceptance Criteria
Tool 2:
datetime_formatGoal
Convert a normalized timestamp into a compact user-facing representation.
Non-Goals
This tool must not:
Supported Styles
shortlongdate_onlytime_onlyweekday_dateInput Contract
Input must be JSON with:
timestamp(required): RFC3339 timestampstyle(required): one of the supported stylestarget_timezone(optional): IANA timezone namelocale(optional, future-safe): string such asenorruIf
target_timezoneis provided, the timestamp must first be converted to that timezone before formatting.Output Contract
Output must be compact JSON.
Example:
Formatting Rules
Suggested defaults:
short→YYYY-MM-DD HH:MMlong→YYYY-MM-DD HH:MM TZdate_only→YYYY-MM-DDtime_only→HH:MMweekday_date→Monday, 2026-04-20Keep formatting intentionally simple and machine-stable unless locale support is explicitly expanded later.
Validation Rules
timestampmust be valid RFC3339stylemust be recognizedtarget_timezone, if present, must be a valid IANA timezoneError Contract
Same structure as
datetime_math:Recommended error codes:
invalid_timestampinvalid_timezoneinvalid_stylemissing_required_fieldinternal_errorBehavior Notes
target_timezoneis provided, format the timestamp in its own offset/location.Implementation Notes (Go)
func ExecuteDatetimeFormat(ctx context.Context, input DatetimeFormatInput) (DatetimeFormatOutput, error)"en".Testing Requirements
Add table-driven tests for:
Acceptance Criteria
Shared Design Constraints
Both tools must:
Future Extensions (Not Required in V1)
Possible later additions:
Follow-up of #92