Documentation

Working Hours Checker

This action checks if the current date and time (at the time of execution) falls within specified working hours, taking into account different configurations, timezones, and excluded dates.

Inputs

NameTypeDescription
TimezoneStringThe timezone for which to check working hours (e.g., "Europe/London", "America/New_York")
Working Hours ConfigStringConfiguration type for working hours. Options: "standard week hours", "weekday weekend split", "custom days and hours"
Standard Start TimeOptional StringStart time for standard week hours (e.g., "09:00")
Standard End TimeOptional StringEnd time for standard week hours (e.g., "17:00")
Weekday Start TimeOptional StringStart time for weekdays in weekday/weekend split (e.g., "08:00")
Weekday End TimeOptional StringEnd time for weekdays in weekday/weekend split (e.g., "18:00")
Weekend Start TimeOptional StringStart time for weekends in weekday/weekend split (e.g., "10:00")
Weekend End TimeOptional StringEnd time for weekends in weekday/weekend split (e.g., "16:00")
Custom Hours SettingsOptional ObjectCustom working hours for specific days or day ranges
Excluded DatesOptional ListList of dates to be excluded in DD-MM-YYYY format

Outputs

NameTypeDescription
SuccessBooleanIndicates if the check was performed successfully
Is Working HoursBooleanWhether the current time is within working hours
ReasonOptional StringReason why it's not working hours (if applicable)
Raw Date TimeStringRaw date and time in ISO 8601 format
Formatted Date TimeStringFormatted date and time (YYYY-MM-DD HH:mm:ss)
ErrorOptional StringError message if any

Timezone Implementation

This function uses the moment-timezone library to handle timezone conversions accurately. It accounts for Daylight Saving Time (DST) and other seasonal time differences automatically. When you specify a timezone, the function uses the current time in that timezone for all calculations, ensuring that working hours are correctly determined regardless of DST changes.

Flexible Configuration

The Working Hours Checker offers three main configuration types to accommodate various business needs:

  1. Standard Week Hours: Use this for businesses with the same working hours every day of the week.
  2. Weekday/Weekend Split: This option allows for different hours on weekdays and weekends.
  3. Custom Days and Hours: This provides the most flexibility, allowing different working hours for specific days or day ranges.

Additionally, the Excluded Dates option allows businesses to specify dates that should be considered non-working days, such as holidays or special events.

Examples (in raw json)

Example 1: Standard 9-5 Business

{
  "timezone": "Europe/London",
  "workingHoursConfig": "standard week hours",
  "standardStartTime": "09:00",
  "standardEndTime": "17:00",
  "excludedDates": ["25-12-2024", "26-12-2024", "01-01-2025"]
}

This configuration is suitable for a business that operates from 9 AM to 5 PM every day, with specific holidays excluded.

Example 2: Retail Store with Different Weekend Hours

{
  "timezone": "America/New_York",
  "workingHoursConfig": "weekday weekend split",
  "weekdayStartTime": "08:00",
  "weekdayEndTime": "20:00",
  "weekendStartTime": "10:00",
  "weekendEndTime": "22:00",
  "excludedDates": ["04-07-2024", "25-12-2024"]
}

This setup works for a retail store with extended hours on weekends and different holiday closures.

Example 3: Restaurant with Varied Hours

{
  "timezone": "Asia/Tokyo",
  "workingHoursConfig": "custom days and hours",
  "customHoursSettings": {
    "Monday-Thursday": { "Start_Time": "11:00", "End_Time": "22:00" },
    "Friday-Saturday": { "Start_Time": "11:00", "End_Time": "23:00" },
    "Sunday": { "Start_Time": "12:00", "End_Time": "21:00" }
  },
  "excludedDates": ["01-01-2025"]
}

This configuration is ideal for a restaurant with different closing times throughout the week and a closure on New Year's Day.

Example 4: International Business with Multiple Timezones

For businesses operating across multiple timezones, you can create separate configurations for each timezone:

// Configuration for London office
{
  "timezone": "Europe/London",
  "workingHoursConfig": "standard week hours",
  "standardStartTime": "09:00",
  "standardEndTime": "17:00",
  "excludedDates": ["25-12-2024", "26-12-2024"]
}

// Configuration for New York office
{
  "timezone": "America/New_York",
  "workingHoursConfig": "standard week hours",
  "standardStartTime": "09:00",
  "standardEndTime": "17:00",
  "excludedDates": ["04-07-2024", "25-12-2024"]
}

These configurations allow for checking working hours in different offices, each with their local timezone and holidays.

Flexibility Explained

  1. Timezone Handling: By using moment-timezone, the function accurately handles different timezones and daylight saving time changes.

  2. Multiple Configuration Types: The three configuration types (standard, weekday/weekend split, and custom) cover a wide range of business hour scenarios.

  3. Custom Day Ranges: In the custom configuration, you can specify hours for individual days or day ranges (e.g., "Monday-Thursday", "Friday-Saturday").

  4. Excluded Dates: This feature allows for easy handling of holidays or other non-working days without changing the main configuration.

  5. Optional Inputs: Many inputs are optional, allowing users to provide only the necessary information for their specific use case.