Skip to content

Instantly share code, notes, and snippets.

@vnbaaij
Created July 18, 2022 09:09
Show Gist options
  • Save vnbaaij/0638c9a55d62b74c355ae5692cf303cd to your computer and use it in GitHub Desktop.
Save vnbaaij/0638c9a55d62b74c355ae5692cf303cd to your computer and use it in GitHub Desktop.
<h2>Selected dates</h2>
<p>
<FluentCalendar DisabledDates=@disabledDates @bind-SelectedDates =@selectedDates></FluentCalendar>
</p>
<p>Dates Selected:</p>
<ul>
@foreach(DateOnly date in selectedDates)
{
<li>@date.ToString("yyyy-MM-dd")</li>
}
</ul>
@code {
static int currentYear = DateTime.Now.Year;
static int currentMonth = DateTime.Now.Month;
static int daysInMonth = DateTime.DaysInMonth(currentYear, currentMonth) + 1;
static Random random = new();
List<DateOnly> disabledDates = new();
List<DateOnly> selectedDates = new();
protected override void OnInitialized()
{
for (int i = 0; i < 3; i++)
{
disabledDates.Add(new DateOnly(currentYear, currentMonth, random.Next(1, daysInMonth)));
selectedDates.Add(new DateOnly(currentYear, currentMonth, random.Next(1, daysInMonth)));
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment