A Date Range defines an inclusive period bounded by a start BACnet.Protocol.BACnetDate and
an end BACnet.Protocol.BACnetDate. It is one of the three CHOICE alternatives inside
BACnet.Protocol.CalendarEntry (alongside a specific BACnet.Protocol.BACnetDate and
a BACnet.Protocol.WeekNDay pattern).
Date ranges are the natural way to express holiday blocks, maintenance windows, or temporary schedule overrides that span multiple consecutive days.
BACnet Specification References
- ASN.1 (Clause 21):
BACnetDateRange ::= SEQUENCE { startDate Date, endDate Date } - Usage (Clause 12):
date_listproperty of Calendar objects (asBACnet.Protocol.CalendarEntryCHOICE)exception_scheduleof Schedule objects (asBACnet.Protocol.SpecialEvent.period)ReadRange"by time" requests (start/stop as date+time)
- Both endpoints are inclusive.
This module also provides a small helper to convert a fully-specified range
into an Elixir Date.Range for easier processing.
Examples
iex> range = %DateRange{
...> start_date: %BACnetDate{year: 2025, month: 6, day: 1, weekday: 7},
...> end_date: %BACnetDate{year: 2025, month: 6, day: 30, weekday: 1}
...> }
iex> {:ok, elixir_range} = DateRange.get_date_range(range)
iex> elixir_range.first
~D[2025-06-01]See Also
Summary
Types
Inclusive start/end date pair used inside BACnet.Protocol.CalendarEntry and BACnet.Protocol.SpecialEvent
(and for ReadRange by time). Dates may contain wildcards.
Functions
Encodes a BACnet date range into BACnet application tags encoding.
Get a Date.Range struct for this date range. Only specific dates are allowed.
Parses a BACnet date range from BACnet application tags encoding.
Validates whether the given BACnet date range is in form valid.
Types
@type t() :: %BACnet.Protocol.DateRange{ end_date: BACnet.Protocol.BACnetDate.t(), start_date: BACnet.Protocol.BACnetDate.t() }
Inclusive start/end date pair used inside BACnet.Protocol.CalendarEntry and BACnet.Protocol.SpecialEvent
(and for ReadRange by time). Dates may contain wildcards.
Functions
@spec encode(t(), Keyword.t()) :: {:ok, BACnet.Protocol.ApplicationTags.encoding_list()} | {:error, term()}
Encodes a BACnet date range into BACnet application tags encoding.
@spec get_date_range(t()) :: {:ok, Date.Range.t()} | {:error, term()}
Get a Date.Range struct for this date range. Only specific dates are allowed.
@spec parse(BACnet.Protocol.ApplicationTags.encoding_list()) :: {:ok, {t(), rest :: BACnet.Protocol.ApplicationTags.encoding_list()}} | {:error, term()}
Parses a BACnet date range from BACnet application tags encoding.
Validates whether the given BACnet date range is in form valid.
It only validates the struct is valid as per type specification.