Nous.Tools.DateTimeTools (nous v0.13.3)

View Source

Built-in tools for date and time operations.

These tools provide common date/time functionality that AI agents often need:

  • Get current date/time in various formats
  • Parse and format dates
  • Calculate date differences
  • Check business days and weekends
  • Timezone conversions

Usage

agent = Nous.new("lmstudio:qwen3-vl-4b-thinking-mlx",
  tools: [
    &DateTimeTools.current_date/2,
    &DateTimeTools.current_time/2,
    &DateTimeTools.current_datetime/2
  ]
)

{:ok, result} = Nous.run(agent, "What day is today?")

Summary

Functions

Add or subtract days from a date.

Get the current date in the specified format.

Get the current date and time together.

Get information about the current month.

Get the current time in the specified format.

Get the start and end of the current week.

Calculate the difference between two dates.

Get the day of the week for a given date.

Check if a date is a weekend.

Parse a human-readable date string.

Functions

add_days(ctx, args)

Add or subtract days from a date.

Arguments

  • date: Date in ISO8601 format (YYYY-MM-DD), defaults to today
  • days: Number of days to add (positive) or subtract (negative)

current_date(ctx, args)

Get the current date in the specified format.

Arguments

  • format: "iso8601" (default), "us" (MM/DD/YYYY), "eu" (DD/MM/YYYY), "full" (Monday, January 1, 2025)
  • timezone: Optional timezone (e.g., "America/New_York", "Europe/London", "UTC")

current_datetime(ctx, args)

Get the current date and time together.

Arguments

  • format: "iso8601" (default), "rfc3339", "unix", "human"
  • timezone: Optional timezone

current_month(ctx, args)

Get information about the current month.

Arguments

  • timezone: Optional timezone

current_time(ctx, args)

Get the current time in the specified format.

Arguments

  • format: "24h" (default, HH:MM:SS), "12h" (hh:MM:SS AM/PM), "short" (HH:MM)
  • timezone: Optional timezone

current_week(ctx, args)

Get the start and end of the current week.

Arguments

  • timezone: Optional timezone
  • week_start: Day to consider start of week (1=Monday default, 7=Sunday)

date_difference(ctx, args)

Calculate the difference between two dates.

Arguments

  • date1: First date in ISO8601 format (YYYY-MM-DD)
  • date2: Second date in ISO8601 format (YYYY-MM-DD)
  • unit: "days" (default), "weeks", "months", "years"

day_of_week(ctx, args)

Get the day of the week for a given date.

Arguments

  • date: Date in ISO8601 format (YYYY-MM-DD), defaults to today

is_weekend(ctx, args)

Check if a date is a weekend.

Arguments

  • date: Date in ISO8601 format (YYYY-MM-DD), defaults to today

parse_date(ctx, args)

Parse a human-readable date string.

Arguments

  • date_string: Date in various formats (ISO8601, MM/DD/YYYY, DD/MM/YYYY, etc.)
  • format: Expected format hint ("iso8601", "us", "eu")