> For the complete documentation index, see [llms.txt](https://docs.avonnicomponents.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avonnicomponents.com/flow/tutorials/components/calendar/block-past-dates-and-limit-working-hours.md).

# Block past dates and limit working hours

Show only the team's working days and hours on the Avonni Calendar, and stop users from creating or moving an event into the past.

A field service team works Monday to Friday, 08:00 to 18:00. The dispatcher should never see Saturday on the board, and a visit dropped on yesterday by mistake is a visit nobody will make. Available Times hides the days and hours the team doesn't work, and Prevent Past Event Creation keeps new and moved events out of the past.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FTymTjzCiAutUc2slX5iz%2Fcalendar-block-past-dates-and-limit-working-hours-result.png?alt=media" alt="Avonni Calendar in a screen flow, Week view showing only Monday 16 to Friday 20 November, from 8 AM to 6 PM, with field service visits"><figcaption></figcaption></figure>

## Before you start

* A screen flow with an Avonni Calendar that shows the team's events. See [Calendar 101](/flow/tutorials/components/calendar/calendar-101-tutorial.md).
* Prevent Past Event Creation only matters once users can create or move events. Set that up with [Create an event by dragging and save it](/flow/tutorials/components/calendar/how-to-create-events-by-dragging-in-the-avonni-calendar.md) or [Reschedule events with drag and drop](/flow/tutorials/components/calendar/how-to-reschedule-events-with-drag-and-drop.md).

## Steps

{% stepper %}
{% step %}

### Keep only the working days

* In the Component Builder, open the **Properties** tab and expand **Available Times**.
* In **Days**, select Monday, Tuesday, Wednesday, Thursday and Friday. Each day you pick shows as a pill you can remove.
* Leave **Days** empty to show every day of the week.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FwohGffeoAM5oz9dlk6MA%2Fcalendar-block-past-dates-and-limit-working-hours-panel.png?alt=media" alt="Calendar Properties tab, Available Times group: Days with Monday to Friday selected, Months empty, and one Time Frame from 8:00 AM to 6:00 PM with an Add Item button" width="320"><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Set the working hours

* In **Time Frames**, click **Add Item** and set the start to 8:00 AM and the end to 6:00 PM.
* For a lunch break, add two time frames: 08:00 to 12:00 and 13:00 to 18:00.
* If you map the value instead of picking it, write each frame as `start-end` in 24 hour time, for example `08:00-18:00`.
  {% endstep %}

{% step %}

### Limit the months (optional)

* **Months** works like **Days**. A team that only installs in season can keep April to October.
* Leave it empty to show every month.
  {% endstep %}

{% step %}

### Block the past

* Open the **Interactions** tab.
* At the top, turn on **Prevent Past Event Creation**.
* Users can no longer create an event that starts before now, or move an existing event into the past.
  {% endstep %}

{% step %}

### Save and test

* Save the Component Builder, save the flow and run it in **Debug**.
* The calendar shows Monday to Friday, from 08:00 to 18:00.
* Drag across a slot from yesterday: no event is created.
  {% endstep %}
  {% endstepper %}

{% hint style="info" %}
These settings change what the calendar shows and what users can do in it. They don't change your records: an Event created at 19:00 by another process still exists in Salesforce. To refuse it everywhere, add a validation rule on Event.
{% endhint %}

## Related tutorials

* [Customize the time spans](/flow/tutorials/components/calendar/how-to-customize-time-spans.md): pair working hours with a 3 day or 1 week view.
* [Create an event by dragging and save it](/flow/tutorials/components/calendar/how-to-create-events-by-dragging-in-the-avonni-calendar.md): the drag that Prevent Past Event Creation guards.
* [Reschedule events with drag and drop](/flow/tutorials/components/calendar/how-to-reschedule-events-with-drag-and-drop.md): move visits and save the new time.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.avonnicomponents.com/flow/tutorials/components/calendar/block-past-dates-and-limit-working-hours.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
