# Opening Hours Model

Opening hours of some MPC entities are represented by arrays of items (OpeningHoursItem) where each defines entity's working hours for given day.


## Model

<DataSchema id="405479" />

Items with `weekday` type specify **regular** working hours for each day of the week (API always returns at least one item for each week day).

Valid `period` values for this type are: `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `saturday`, `sunday`.

Items with type `day` specify **special** working hours for specific day (`period` has `YYYY-MM-DD` format) that override regular ones.

Any day may have opening time defined in multiple periods (`hours` do not overlap). 
For instance, in attached example, on `tuesday` the entity is open in two periods: 
`10:00-15:00` and `16:00-18:00` with a one hour break between them.

Items returned from API are sorted in following order:

<Steps>
  <Step>
    `type ASC` (weekday &lt; day)
  </Step>
  <Step>
    `period ASC` (chronological order)
  </Step>
  <Step>
    `hours.opens_at ASC` (chronological order)
  </Step>
</Steps>

## Example 

Array of OpeningHoursItem for some object:

```json

[
  { "type": "weekday", "period": "monday", "hours": { "opens_at": "10:00", "closes_at": "18:00" } },
  { "type": "weekday", "period": "tuesday", "hours": { "opens_at": "10:00", "closes_at": "15:00" } },
  { "type": "weekday", "period": "tuesday", "hours": { "opens_at": "16:00", "closes_at": "18:00" } },
  { "type": "weekday", "period": "wednesday", "hours": { "opens_at": "10:00", "closes_at": "18:00" } },
  { "type": "weekday", "period": "thursday", "hours": { "opens_at": "10:00", "closes_at": "18:00" } },
  { "type": "weekday", "period": "friday", "hours": {"opens_at": "10:00", "closes_at": "18:00" } },
  { "type": "weekday", "period": "saturday", "hours": { "opens_at": "12:00", "closes_at": "15:00" } },
  { "type": "weekday", "period": "sunday", "hours": null },
  { "type": "day", "period": "2023-05-01", "hours": null },
  { "type": "day", "period": "2023-12-22", "hours": { "opens_at": "12:00", "closes_at": "14:00" } },
  { "type": "day", "period": "2023-12-25", "hours": null, "description": { "en": "Christmas", "no": "Jul"} }
]

```

