# Proposed features/Time domains

Time domains
Status: Proposed (under way)
Proposed by: Eckhart
Applies to:
Definition: Time domains (mainly) for use in conditional restrictions
Rendered as:
Drafted on: 2012-11-04

## Rationale

While opening_hours=* gives a few examples for time domains, it is very hard to deduce the actual rules that can be used to construct time domains. This proposal tries to list proper rules to construct time domains. It also adds years.

## Rules

• A time domain is either the special value 24/7 or a ";"-separated list of rules.
Example: Mo-Fr 08:00-20:00; Sa 08:00-16:00
Here Mo-Fr 08:00-20:00 is the first rule, and Sa 08:00-16:00 is the second rule.
• Each rule consists of an optional day part followed by a mandatory time part, separated by " ".
Example: Mo-Fr 08:00-12:00, 14:00-20:00
Here Mo-Fr is the day part, and 08:00-12:00, 14:00-20:00 is the time part.
• When a rule contains no day part, it applies to every day.
Example: 06:00-20:00
Here 06:00-20:00 is the time part, and the day part been omitted. This rule therefore applies to every day.

### Evaluation

The order in which rules are specified is important, in the following manner: For a given day and time, the right-most rule whose day part matches the day wins.

Example: Mo-Fr 08:00-16:00; We 08:00-20:00
Assuming it is Wednesday, the day part of the second rule (We) matches, and therefore We 08:00-20:00 is used.

Example: Mo-Fr 08:00-12:00; 14:00-20:00
Since the second rule applies to every day, the first rule is completely irrelevant – most likely this was not intended.

## Day part

• The day part is a space-separated list of day specifiers.
A day part applies only if all day specifiers apply.
Example: Jan 1-Apr 15 Mo-Fr
The above day part consists of two day specifiers: Jan 1-Apr 15 and Mo-Fr. It therefore applies on Monday through Friday between January 1st and April 15th.
• A day specifier can be:
1. An exact date or date interval list: written as a comma-separated list using entries out of
YEAR MMM DD
YEAR MMM
MMM DD
YEAR
YEAR MMM DD-YEAR MMM DD
MMM DD-MMM DD
MMM-MMM
where YEAR is the four-digit year, MMM is the three-letter abbreviation of the month (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec) and DD is the day of month.
Example: 2012 Jan 12-2013 Jul 29
Example: Jun 15-Jul 14
Example: Jan-Feb, Aug-Oct
2. A day list: the keyword day followed by a comma-separated list using entries out of DD or DD-DD, where DD are day numbers.
Example: day 1-15
Specifies the first 15 days of each month.
3. A week list: the keyword week followed by a comma-separated list using entries out of WW, WW-WW or WW-WW/n, where WW are week numbers, and n is the periodicity.
Example: week 2-52/2
Specifies every second week from week 2 through week 52, i.e. every even week.
4. A weekday list: one or more values out of Mo, Tu, We, Th, Fr, Sa, Su, SH, PH, separated by "," or – in the case of consecutive weekdays – by "-".
Mo: monday, Tu: Tuesday, We: Wednesday, Th: Thursday, Fr: Friday, Sa: Saturday, Su: Sunday, SH: school holiday, PH: public holiday.
Example: Sa-Su,PH
• Day specifiers always appear in the above order.
• Use as few day specifiers as possible.
Example: Jan 1-Dec 31 Mo-Su 08:00-16:00

## Time part

• The time part is either a comma-separated list of time intervals, points in time, or the special keyword off to denote that there are no time intervals / points in time. (The use of time intervals vs. points in time depends on the application.)
Example: 08:00-12:00, 14:00-20:00
The above example contains two time intervals: 08:00-12:00 as the first interval, 14:00-20:00 as the second interval.
• A point in time is written in 24-hour format as HH:MM.
Example: 12:00
Leading zeroes should always get included.
• A time interval is written in 24-hour format as HH:MM-HH:MM.
Example: 08:00-12:00
Leading zeroes should always get included.
• For time intervals, if the start time is later than the end time, the time interval wraps onto the next day.
Example: 22:00-06:00
This is equivalent to 00:00-06:00, 22:00-24:00.
Note that while the wrap is onto the next day, it is treated as if it belongs to the same day (see following examples which explain how this is meant).
Example: Mo 20:00-03:00; Tu 18:00-21:00
In the above example second rule does not overide the fact, that Tuesday morning from 00:00-03:00 estabilishment is open (this is because the first rule "belongs" to Monday, so it is not overriden by Tuesday rule).
Example: 20:00-03:00; Mo off
In the above example, both Monday evening and Tuesday morning are affected by the second rule.
• For time intervals, sunrise and sunset can be used instead of start times or end times.
Example: 10:00-sunset
• An offset can be specified for both sunset and sunrise, using (sunset±HH:MM) or (sunrise±HH:MM).
Example: 10:00-(sunset-01:00)
This specifies a time interval from 10:00 till one hour before sunset.