Grammar for time domain values

  • Is compatible with the proposals examples (except the time is obligatory)
  • Covers all values I found (as far a formal expression is possible at all).
  • The very common plain text conditions can be expressed as "…" comments.
  • Can be evaluated sufficently simple™.

Legend:

  • | separates alternatives.
  • [ and ] bracket optional components.
  • { and } bracket optional repeatable components.
  • Multiple productions for one symbol connote alternatives.
Symbol Definition Comment
time_domain
<time_domain> 24/7 → open
<fallback_group> { || <fallback_group> } [1]
<fallback_group> <rule_sequence> { ; <rule_sequence> }
<rule_sequence> [ <calendar_ranges> : ] <basic_rule> { ; <basic_rule> } [2]
Basic rule
<basic_rule> <times_for_days> { , <times_for_days> } [3]
<times_for_days> open [ <comment> ] → open
closed [ <comment> ] → closed
unknown [ <comment> ] → unknown
<comment>
<day_list> off → closed
[ <day_list> ] <times> → open
[ <day_list> ] <times> open [ <comment> ]
[ <day_list> ] <times> closed [ <comment> ] → closed
[ <day_list> ] <times> unknown [ <comment> ] → unknown
[ <day_list> ] <times> <comment>
Days
<day_list> <day_or_days> { , <day_or_days> } or
<day_or_days> [ <weeks> ] { <holiday> } <days>
[ <weeks> ] { <holiday> } <holiday> [ ± <number> days ]
<holiday> SH | PH
<days> <wday> [4]
<wday> - <wday>
<wday> [ <nth_entry> { , <nth_entry> } ]
<mday>
<mday> - <mday>
<mday> - <mday> / <number> [5]
<nth_entry> <nth>
<nth> - <nth>
- <nth>
<nth> 1 | 2 | 3 | 4 | 5
<weeks> week <week> { , <week> } or
<week> <weeknum>
<weeknum> - <weeknum>
<weeknum> - <weeknum> / <number> [5]
Times
<times> <timespan> { , <timespan> } or
<timespan> <time>
<time> + [6]
<time> - <time> [7]
<time> - <time> +
<time> - <time> / <minute> [8]
<time> - <time> / <hour_minutes>
<time> <hour_minutes> | <variable_time>
<variable_time> <event>
<event> + <hour_minutes> hours
<event> - <hour_minutes> hours
<event> sunrise | sunset | …
Calendar
<calendar_ranges> <calendar_days> { , <calendar_days> } or
<comment> [9]
<calendar_days> [ <year> ] <month>
[ <year> ] <month> - <month>
[ <year> ] summer [10]
[ <year> ] winter
<date_with_offsets> [11]
<date_with_offsets> + [12]
<date_with_offsets> - <date_with_offsets> [13]
<date_with_offsets> <date> [ ± <wday> ] [ ± <number> days ] [14]
<date> [ <year> ] <month> <daynum>
[ <year> ] <month> <wday> [ [-] <nth> ]
[ <year> ] <variable_date>
<daynum> [15]
<variable_date> easter | …
Basic elements
<wday> Su | Mo | Tu | We | Th | Fr | Sa
<weeknum> 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53
<month> Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec
<daynum> 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31
<mday> 01. | 02. | 03. | 04. | 05. | 06. | 07. | 08. | 09. | 10. | 11. | 12. | 13. | 14. | 15. | 16. | 17. | 18. | 19. | 20. | 21. | 22. | 23. | 24. | 25. | 26. | 27. | 28. | 29. | 30. | 31.
<hour_minutes> <hour>:<minute>
<hour> 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24
<minute> 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60
<comment> " {Any character except " and ;} "
  1. Groups are evaluated from left to right, until one group evaluates to open.

    In discussion ! was proposed as not operator; obviously intended was a shortcut-or.
    Tentatively I introduces ||: one will not type it by chance, it exhibits the cut very good, and every programmer will understand it immediately.

  2. A basic_rule is applicable to a day on a all-or-nothing base. The result of evaluating a rule_sequenz is the result of the last rule, which is applicable to the particular day.
  3. The components of a basic_rule are additive: the comma between the components is read as and also.
  4. Su represents all sundays, Su[1] represents the first sunday of a month, Su[-1] represents the last sunday of a month.
  5. This notation is borrowed from cron and enables to express in even weeks or on odd days.
  6. Open end: the opening time starts at the given time with open end. This kind of indication is used quite often; but of course it is impossible to evaluate it verbatim. I evaluate this notation as plus 4 hours, but no later than midnight.
  7. If the second time is earlier then the first one, it is assumed to be on the next day.
    The condition evals to true, if first timeparticular time < last time holds.
  8. This notation describes a repeated event: 10:00-16:00/90 and 10:00-16:00/1:30 are evaluated as from ten am to four pm every 1½ hours. Especially departure times can be written very concise and compact using this notation. The interval time following the / is valid but ignored for opening_hours.
  9. Sometimes you cannot (yet) specify exactly the valid calendar days.
    In this case you can use plain text in a comment followed by : .
  10. Calendar ranges were specified by summer and winter quite often.
    I evaluate summer to May-Oct and winter to Nov-Apr.
  11. Evaluates to true of the date to check equals this day, to false otherwise.
  12. Until further notice: the calendar range starts at this date and has no upper limit.
  13. Evaluates to true, if from-dateday-to-checkto-date holds. Evaluates to true, if from-date > to-date holds, year is not specified and either day-to-checkfrom-date or day-to-checkto-date holds. Evaluates to false otherwise.
  14. Given any calendar day, the notation + Su selectes the first Sunday after this calendar day, the notation - Su selectes the last Sunday before this calendar day.
  15. A day missing a month is assumed to refer to the last month found before.

Dieser Text in deutscher Sprache