Phil Scott 223642b797
Add blog to docs (#484)
* Adding social card infrastructure
* Upgrades doc project to .NET 6
* Adds Playwright
* Changes the console to a web project for Playwright
* Adds social card template
* Added blog content
* Parallelized social image processing
* Updating CI to use .NET 6 for docs build
2021-07-15 19:53:01 +02:00

1.6 KiB

Title: Calendar Order: 40 RedirectFrom: calendar Description: "The Calendar is used to render a calendar to the terminal." Highlights: - Include highlighted events. - Culture aware. - Custom headers.

The Calendar is used to render a calendar to the terminal.

Usage

To render a calendar, create a Calendar instance with a target date.

var calendar = new Calendar(2020,10);
AnsiConsole.Render(calendar);

Culture

You can set the calendar's culture to show localized weekdays.

var calendar = new Calendar(2020,10);
calendar.Culture("ja-JP");
AnsiConsole.Render(calendar);

Header

You can hide the calendar header.

var calendar = new Calendar(2020,10);
calendar.HideHeader();
AnsiConsole.Render(calendar);

You can set the header style of the calendar.

var calendar = new Calendar(2020, 10);
calendar.HeaderStyle(Style.Parse("blue bold"));
AnsiConsole.Render(calendar);

Calendar Events

You can add an event to the calendar. If a date has an event associated with it, the date gets highlighted in the calendar.

var calendar = new Calendar(2020,10);
calendar.AddCalendarEvent(2020, 10, 11);
AnsiConsole.Write(calendar);

You can set the highlight style for a calendar event via SetHighlightStyle.

var calendar = new Calendar(2020, 10);
calendar.AddCalendarEvent(2020, 10, 11);
calendar.HighlightStyle(Style.Parse("yellow bold"));
AnsiConsole.Write(calendar);