A Calendar Entry is the CHOICE type used by both Calendar objects and Schedule objects to describe "special" days (holidays, maintenance periods, after-hours operation, etc.).
The three alternatives (defined in Clause 21) are:
:date- a single specific (or partially unspecified)BACnet.Protocol.BACnetDate:date_range- an inclusiveBACnet.Protocol.DateRange:week_n_day- a recurringBACnet.Protocol.WeekNDaypattern
This single type is deliberately reused in multiple places so that matching logic ("does today match any exception?") can be written once.
BACnet Specification References
- ASN.1 (Clause 21):
BACnetCalendarEntry ::= CHOICE { date Date, dateRange BACnetDateRange, weekNDay BACnetWeekNDay } - Calendar object (12.9):
date_listproperty isBACnetARRAYofBACnet.Protocol.CalendarEntry. - Schedule object (12.24):
exception_schedulecontainsBACnet.Protocol.SpecialEventwhoseperiodcan be aBACnet.Protocol.CalendarEntryor an object identifier referencing a Calendar object.
Examples
Specific date entry
iex> entry = %CalendarEntry{type: :date, date: %BACnetDate{year: 2025, month: 12, day: 25, weekday: 4}, date_range: nil, week_n_day: nil}
iex> entry.type
:dateDate range entry
iex> entry = %CalendarEntry{type: :date_range, date_range: %DateRange{start_date: %BACnetDate{year: 2025, month: 7, day: 1, weekday: 2}, end_date: %BACnetDate{year: 2025, month: 7, day: 31, weekday: 4}}, date: nil, week_n_day: nil}
iex> entry.type
:date_rangeRecurring WeekNDay entry
iex> entry = %CalendarEntry{type: :week_n_day, week_n_day: %WeekNDay{month: :unspecified, week_of_month: 3, weekday: 2}, date: nil, date_range: nil}
iex> entry.type
:week_n_daySee Also
Summary
Types
CHOICE of a single date, date range, or BACnet.Protocol.WeekNDay pattern
(see BACnet.Protocol.CalendarEntry module docs + ASN.1 in Clause 21).
Used in Calendar date_list and Schedule exception schedules.
Functions
Encode a calendar entry into application tag-encoded.
Parse application tag-encoded calendar entry into a struct.
Validates whether the given BACnet calendar entry is in form valid.
Types
@type t() :: %BACnet.Protocol.CalendarEntry{ date: BACnet.Protocol.BACnetDate.t() | nil, date_range: BACnet.Protocol.DateRange.t() | nil, type: :date | :date_range | :week_n_day, week_n_day: BACnet.Protocol.WeekNDay.t() | nil }
CHOICE of a single date, date range, or BACnet.Protocol.WeekNDay pattern
(see BACnet.Protocol.CalendarEntry module docs + ASN.1 in Clause 21).
Used in Calendar date_list and Schedule exception schedules.
Functions
@spec encode(t(), Keyword.t()) :: {:ok, BACnet.Protocol.ApplicationTags.encoding_list()} | {:error, term()}
Encode a calendar entry into application tag-encoded.
@spec parse(BACnet.Protocol.ApplicationTags.encoding_list()) :: {:ok, {t(), rest :: BACnet.Protocol.ApplicationTags.encoding_list()}} | {:error, term()}
Parse application tag-encoded calendar entry into a struct.
Validates whether the given BACnet calendar entry is in form valid.
It only validates the struct is valid as per type specification.