Aerostack
build

datetime-business-hours Edge Function — Utilities

Utilities

Check if a datetime falls within business hours and return the next opening time.

navin @navin verified
Updated Mar 12, 2026
GitHub

Edge function datetime-business-hours Check if a datetime falls within business hours and return the next opening time.. Deployed on Cloudflare Workers — zero cold starts, globally distributed. Mount it via your Aerostack workspace to call it from any AI agent.

terminal — aerostack cli
$ npx aerostack add navin/datetime-business-hours
smart_toy

Use with AI Assistants

MCP

Connect Claude, Cursor, or any MCP-compatible client — then call this function by slug

① Add MCP Server

Add this once — access all Aerostack functions from your AI tool.

claude_desktop_config.json
{
  "mcpServers": {
    "aerostack": {
      "url": "https://mcp.aerostack.dev",
      "type": "http"
    }
  }
}

② Call this function

Ask your AI to use the call_function tool with this slug:

call_function
call_function({
  slug: "datetime-business-hours",
  args: {
    "date": null,
    "options": null
  }
})

datetime-business-hours — Check if a time is within business hours

Determine whether a datetime is within business hours and find the next opening time, with full timezone and custom schedule support.


API

POST /api/datetime-business-hours

Request body

Field Type Required Default Description
date string | number Date/time to check
options.timezone string 'UTC' IANA timezone
options.start string '09:00' Business start time (HH:mm)
options.end string '17:00' Business end time (HH:mm)
options.workDays number[] [1,2,3,4,5] Work day numbers (0=Sun...6=Sat)

Success response (200)

{
  "success": true,
  "data": {
    "inBusinessHours": true,
    "dayOfWeek": 1,
    "localTime": "10:30",
    "nextOpen": "2024-01-16T09:00:00.000Z"
  }
}

Usage

Direct import
import { datetimeBusinessHours } from '@aerostack/functions/datetime-business-hours';

const result = datetimeBusinessHours({
  date: Date.now(),
  options: { timezone: 'America/New_York', start: '09:00', end: '18:00' }
});

if (!result.inBusinessHours) {
  console.log('Next open:', result.nextOpen);
}

Use Cases

  • Routing support tickets to live agents only during business hours
  • Calculating SLA response windows that exclude weekends and nights
  • Scheduling automated messages to send only within work hours

Metadata

upgrade Version 1.0.0
gavel License MIT
language Language typescript
cloud Provider aerostack

Tags

datetime
deployed_code

Build and publish your own functions

Write a TypeScript function, deploy it to the edge, and share it with thousands of developers — in minutes.

More Utilities Functions

Browse Utilities Functions →

Frequently asked questions

What does the datetime-business-hours function do? +

datetime-business-hours is a serverless edge function for utilities automation written in aerostack. Deploy it to Cloudflare Workers via your Aerostack workspace.

How do I deploy the datetime-business-hours function? +

Install the Aerostack CLI and run: ```bash aerostack deploy function @navin/datetime-business-hours ``` It will be live on Cloudflare Workers in seconds.

What runtime does datetime-business-hours use? +

datetime-business-hours runs on aerostack on the Cloudflare Workers edge runtime — zero cold starts, globally distributed.

Can I customise the datetime-business-hours function? +

Yes. Fork the function from your Aerostack dashboard, modify the source, and redeploy. All changes are version-controlled.