datetime-business-hours Edge Function — Utilities
UtilitiesCheck if a datetime falls within business hours and return the next opening time.
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.
npx aerostack add navin/datetime-business-hours Use with AI Assistants
MCPConnect 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.
{
"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({
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
Tags
Publisher
@navin verified
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 →datetime-add
by @navin
Add or subtract a duration from a date, supporting units from milliseconds to years with correct month-end handling.
datetime-diff
by @navin
Calculate the difference between two dates in specified units (ms, seconds, minutes, hours, days, weeks, months, years).
datetime-duration-format
by @navin
Format a duration in milliseconds to a human-readable string with long, short, or compact styles.
datetime-format
by @navin
Format a date to a string using format tokens like YYYY-MM-DD HH:mm:ss with optional timezone support.
datetime-parse
by @navin
Parse a date string or unix timestamp to a normalised Unix millisecond timestamp and ISO string.
datetime-relative
by @navin
Format a date as a relative time string like '2 hours ago' or 'in 3 days' using Intl.RelativeTimeFormat.
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.