aitime

package
v0.80.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package aitime provides the time parsing service interface for AI agents. This interface is consumed by Team B (Assistant+Schedule).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockTimeService

type MockTimeService struct {
	// FixedNow can be set to use a fixed "now" for testing
	FixedNow *time.Time
}

MockTimeService is a mock implementation of TimeService for testing.

func NewMockTimeService

func NewMockTimeService() *MockTimeService

NewMockTimeService creates a new MockTimeService.

func (*MockTimeService) Normalize

func (m *MockTimeService) Normalize(ctx context.Context, input string, timezone string) (time.Time, error)

Normalize standardizes time expressions.

func (*MockTimeService) ParseNaturalTime

func (m *MockTimeService) ParseNaturalTime(ctx context.Context, input string, reference time.Time) (TimeRange, error)

ParseNaturalTime parses natural language time expressions.

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser parses natural language time expressions.

func NewParser

func NewParser(timezone *time.Location) *Parser

NewParser creates a new time parser with the given timezone.

func (*Parser) Parse

func (p *Parser) Parse(input string) (time.Time, error)

Parse parses a time expression and returns the parsed time.

func (*Parser) WithTimezone

func (p *Parser) WithTimezone(tz *time.Location) *Parser

WithTimezone returns a new parser with the given timezone.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service implements TimeService with rule-based parsing.

func NewService

func NewService(defaultTimezone string) *Service

NewService creates a new time service.

func (*Service) Normalize

func (s *Service) Normalize(_ context.Context, input string, timezone string) (time.Time, error)

Normalize standardizes time expressions.

func (*Service) ParseNaturalTime

func (s *Service) ParseNaturalTime(_ context.Context, input string, reference time.Time) (TimeRange, error)

ParseNaturalTime parses natural language time expressions.

type TimeRange

type TimeRange struct {
	Start time.Time `json:"start"`
	End   time.Time `json:"end"`
}

TimeRange represents a time range.

type TimeService

type TimeService interface {
	// Normalize standardizes time expressions.
	// Supports: "明天3点", "下午三点", "2026-1-28", "15:00"
	// Returns: standardized time.Time
	Normalize(ctx context.Context, input string, timezone string) (time.Time, error)

	// ParseNaturalTime parses natural language time expressions.
	// reference: reference time point (usually current time)
	// Returns: time range
	ParseNaturalTime(ctx context.Context, input string, reference time.Time) (TimeRange, error)
}

Consumers: Team B (Assistant+Schedule).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL