PhoenixLiveCalendar.DayMarker (PhoenixLiveCalendar v0.1.0)

Copy Markdown View Source

Represents a date-level annotation — holidays, special hours, closures, notices.

Day markers are not events. They annotate the date itself rather than occupying a time slot. They appear as visual indicators on the day cell (background color, label, icon) and can span multiple days.

Use day markers for:

  • Public holidays ("Christmas Day", "New Year")
  • Special operating hours ("Winter hours: 10am-3pm")
  • Office closures ("Office closed for renovation")
  • Seasonal notices ("Peak season — limited availability")
  • Custom date labels ("Payday", "Sprint 12 start")

Day markers can optionally override availability — e.g., a holiday marker with available: false blocks booking, while a "reduced hours" marker with custom availability windows allows booking within those reduced hours.

Examples

# Public holiday — fully closed
%DayMarker{
  id: "xmas",
  label: "Christmas Day",
  start_date: ~D[2026-12-25],
  end_date: ~D[2026-12-26],
  type: :holiday,
  color: "bg-error/20",
  icon: "🎄",
  available: false
}

# Reduced hours — bookable within modified schedule
%DayMarker{
  id: "winter-hours",
  label: "Winter Hours",
  start_date: ~D[2026-12-20],
  end_date: ~D[2027-01-05],
  type: :notice,
  color: "bg-info/10",
  description: "Reduced hours: 10am-3pm",
  availability: [
    %PhoenixLiveCalendar.Availability{
      days_of_week: [1, 2, 3, 4, 5],
      start_time: ~T[10:00:00],
      end_time: ~T[15:00:00]
    }
  ]
}

# Simple label
%DayMarker{
  id: "payday",
  label: "Payday",
  start_date: ~D[2026-04-15],
  type: :label,
  color: "bg-success/10"
}

Summary

Functions

Returns whether this marker covers the given date.

Returns the effective end date (exclusive). Defaults to start + 1 day.

Groups markers by date for a list of dates. Returns %{Date.t() => [t()]}.

Returns all markers that cover a given date from a list.

Returns the number of days this marker spans.

Types

marker_type()

@type marker_type() :: :holiday | :closure | :notice | :label | :season | :custom

t()

@type t() :: %PhoenixLiveCalendar.DayMarker{
  availability: [PhoenixLiveCalendar.Availability.t()] | nil,
  available: boolean(),
  class: String.t() | nil,
  color: String.t() | nil,
  description: String.t() | nil,
  end_date: Date.t() | nil,
  extra: map(),
  icon: String.t() | nil,
  id: term(),
  label: String.t(),
  start_date: Date.t(),
  text_color: String.t() | nil,
  type: marker_type()
}

Functions

covers_date?(marker, date)

@spec covers_date?(t(), Date.t()) :: boolean()

Returns whether this marker covers the given date.

effective_end_date(day_marker)

@spec effective_end_date(t()) :: Date.t()

Returns the effective end date (exclusive). Defaults to start + 1 day.

group_by_date(markers, dates)

@spec group_by_date([t()], [Date.t()]) :: %{required(Date.t()) => [t()]}

Groups markers by date for a list of dates. Returns %{Date.t() => [t()]}.

markers_for_date(markers, date)

@spec markers_for_date([t()], Date.t()) :: [t()]

Returns all markers that cover a given date from a list.

span_days(marker)

@spec span_days(t()) :: pos_integer()

Returns the number of days this marker spans.