# How do Time Groups actually work under the hood?

**URL:** <https://community.freepbx.org/t/how-do-time-groups-actually-work-under-the-hood/108384>\
**Category:** Applications / Modules\
**Tags:** modules, configuration, freepbx\
**Created:** [November 22, 2025, 1:18am UTC](https://community.freepbx.org/t/how-do-time-groups-actually-work-under-the-hood/108384 "2025-11-22T01:18:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zakjonesFDT](https://community.freepbx.org/user_avatar/community.freepbx.org/zakjonesfdt/32/24392_2.png) [@zakjonesFDT](https://community.freepbx.org/u/zakjonesFDT)\
**Post date:** [November 22, 2025, 1:18am UTC](https://community.freepbx.org/t/how-do-time-groups-actually-work-under-the-hood/108384/1 "2025-11-22T01:18:41Z")

</div>

I’m trying to clean up the time groups on several PBX’s, with the goal of making them more readable (feature requests: give me a comment field in a time group definition, and let me re-order entries within a time group).

That’s exposed a gap in my understanding: do time group entries define a contiguous block of time bounded by the specified start/finish, or do they create a series of AND/OR conditions?

For example, say I’m usually open Monday through Saturday, but I want to be closed for Labor Day weekend of 2025. Labor Day was on Sept 1, which means the preceding Saturday was August 30th.

If I add to my “holidays” time group:

```yaml
Month Day Start : 30
Month Day Finish: 1
Month Start: August
Month Finish: September

```

Does this translate as “match August 30th through September 1st”, or as

```javascript
if ((month = 8 OR month = 9) AND (day = 30 OR day = 31 OR day = 1)){
match
}
else{no match}

```

To rephrase, do time groups define an contiguous block of time bounded by the specified start/finish, or do they create a series of OR’s within AND’s?

The second case would result in being closed on both August 1st and September 30th, which is obviously not the goal.

On the other hand, usually I define Labor Day with:

```yaml
Week Day Start: Monday
Week Day Finish: Monday
Month Day Start: 1
Month Day Finish: 7
Month Start: September
Month Finish: September

```

which actually relies on the second case being true, but for 2025 alone would also need matching entries for “last Saturday in August” and “last Sunday in August”, and is _way_ less readable at a glance (not to mention the _other_ entries required if Labor Day falls on any other day of September!).

Different question that might make it easier to understand what I’m asking– what happens if we do:

```yaml
Month Day Start: 30
Month Day Finish: 2
Month Start: August
Month Finish: October

```

Does this match “all days between August 30th and October 2nd”, or does it match August 1st, 2nd, 30th, and 31st; September 1st, 2nd, and 30th (and the mythical 31st); and October 1st, 2nd, 30th, and 31st?

Do day-of-week/day-of-month/month definitions even wrap from high to low?

Practically, I know the answer is that we just need to re-define our holidays each year, because it’s either impossible or very complicated to have an eternally-robust definition of “Labor Day Weekend”, but I’d like to avoid having to do this on _hundreds_ of PBX’s. I’m hoping someone knows something that can help me out.

(ignore the syntax highlight languages; I just wanted to make it pretty for y’all)

TL;DR: Do time groups ever define an contiguous block of time bounded by the specified start/finish, or do they always create a series of OR’s within AND’s?

---

<div class="post-metadata">

**Author:** ![david55](https://community.freepbx.org/letter_avatar_proxy/v4/letter/d/e19adc/32.png) [@david55](https://community.freepbx.org/u/david55)\
**Post date:** [November 22, 2025, 12:47pm UTC](https://community.freepbx.org/t/how-do-time-groups-actually-work-under-the-hood/108384/2 "2025-11-22T12:47:33Z")

</div>

Assuming that FreePBX simply uses Asterisk time conditions, it is the second case; each condition is checked separately and all must be true for a match. This logic is similar to cron in Linux and Unix.

---

<div class="post-metadata">

**Author:** ![madgen](https://community.freepbx.org/user_avatar/community.freepbx.org/madgen/32/32346_2.png) [@madgen](https://community.freepbx.org/u/madgen)\
**Post date:** [November 23, 2025, 4:37am UTC](https://community.freepbx.org/t/how-do-time-groups-actually-work-under-the-hood/108384/3 "2025-11-23T04:37:24Z")

</div>

This is my suggestion…

 ![image](https://community.freepbx.org/uploads/default/original/3X/1/4/143c0233796b18eb20ed49d64cb064f9fd5131e1.png)

```auto
Sat | Sun | Mon
----------------
 30 | 31 | 01
 31 | 01 | 02
 01 | 02 | 03
 02 | 03 | 04
 03 | 04 | 05
 04 | 05 | 06
 05 | 06 | 07
----------------

```

My module will not reorder the database but it will display in order regardless of how they are entered.  
Wrapping days and months will not work. (Aug 28 - Sep 1 or Dec 31 - Jan 2)  
Day of week and hours can wrap. (Thu - Mon or 2200 - 0200)

---

<div class="post-metadata">

**Author:** ![system](https://community.freepbx.org/uploads/default/original/3X/f/7/f7056d57e04fdbf71c6ad967e1ced351317f5c3f.png) [@system](https://community.freepbx.org/u/system)\
**Post date:** [December 23, 2025, 4:38am UTC](https://community.freepbx.org/t/how-do-time-groups-actually-work-under-the-hood/108384/4 "2025-12-23T04:38:09Z")

</div>

Closed on December 23, 2025, 4:38am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
