BACnet.Protocol.CalendarEntry (bacstack v0.1.0-dev.1)

Copy Markdown View Source

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:

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

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
:date

Date 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_range

Recurring 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_day

See Also

Summary

Types

t()

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

t()

@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

encode(entry, opts \\ [])

@spec encode(t(), Keyword.t()) ::
  {:ok, BACnet.Protocol.ApplicationTags.encoding_list()} | {:error, term()}

Encode a calendar entry into application tag-encoded.

parse(tags)

Parse application tag-encoded calendar entry into a struct.

valid?(t)

@spec valid?(t()) :: boolean()

Validates whether the given BACnet calendar entry is in form valid.

It only validates the struct is valid as per type specification.