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.
Please note: Processing Hours Checker action works in the same way, except you can enter any date string instead of the current date time according to timezones.
Inputs
Name | Type | Description |
---|---|---|
Timezone | String | The timezone for which to check working hours (e.g., "Europe/London", "America/New_York") |
Working Hours Config | String | Configuration type for working hours. Options: "standard week hours", "weekday weekend split", "custom days and hours" |
Standard Start Time | Optional String | Start time for standard week hours (e.g., "09:00") |
Standard End Time | Optional String | End time for standard week hours (e.g., "17:00") |
Weekday Start Time | Optional String | Start time for weekdays in weekday/weekend split (e.g., "08:00") |
Weekday End Time | Optional String | End time for weekdays in weekday/weekend split (e.g., "18:00") |
Weekend Start Time | Optional String | Start time for weekends in weekday/weekend split (e.g., "10:00") |
Weekend End Time | Optional String | End time for weekends in weekday/weekend split (e.g., "16:00") |
Custom Hours Settings | Optional Object | Custom working hours for specific days or day ranges |
Excluded Dates | Optional List | List of dates to be excluded in DD-MM-YYYY format |
Outputs
Name | Type | Description |
---|---|---|
Success | Boolean | Indicates if the check was performed successfully |
Is Working Hours | Boolean | Whether the current time is within working hours |
Reason | Optional String | Reason why it's not working hours (if applicable) |
Raw Date Time | String | Raw date and time in ISO 8601 format |
Formatted Date Time | String | Formatted date and time (YYYY-MM-DD HH:mm:ss) |
Error | Optional String | Error 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:
- Standard Week Hours: Use this for businesses with the same working hours every day of the week.
- Weekday/Weekend Split: This option allows for different hours on weekdays and weekends.
- 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
-
Timezone Handling: By using
moment-timezone
, the function accurately handles different timezones and daylight saving time changes. -
Multiple Configuration Types: The three configuration types (standard, weekday/weekend split, and custom) cover a wide range of business hour scenarios.
-
Custom Day Ranges: In the custom configuration, you can specify hours for individual days or day ranges (e.g., "Monday-Thursday", "Friday-Saturday").
-
Excluded Dates: This feature allows for easy handling of holidays or other non-working days without changing the main configuration.
-
Optional Inputs: Many inputs are optional, allowing users to provide only the necessary information for their specific use case.
Updated 2 days ago