Mastering Globalization: Utilizing Calendar Types in .NET MAUI Calendar Control

Mastering Globalization: Utilizing Calendar Types in .NET MAUI Calendar Control

Jollen Moyani
Syncfusion

--

Different regions and cultures follow distinct calendar systems, reflecting their unique traditions and historical context. These calendar systems often vary in month lengths, year starts, and year ends. In today’s globalized world, developing applications that cater to users from diverse cultures and regions is essential.

The Syncfusion .NET MAUI Calendar control provides different calendar types, enabling developers to cater to a broader user base and users to interact with dates according to their cultural or regional preferences.

In this blog, we’ll explore the different calendar types and their basic functionalities in the .NET MAUI Calendar control.

Note: If you are new to this control, refer to the .NET MAUI Calendar getting started documentation for background knowledge.

Different calendar types

The .NET MAUI Calendar supports different calendar types and displays dates, months, and years based on the one specified. Gregorian is the default calendar type.

Different calendar types in .NET MAUI Calendar

You can easily change the calendar type using the Identifier property in the SfCalendar. Refer to the following code example.

<calendar:SfCalendar x:Name="Calendar" Identifier="Hijri"> 
</Calendar:SfCalendar>
Hijri calendar type in .NET MAUI Calendar
Hijri calendar type in .NET MAUI Calendar

Different calendar views

The .NET MAUI Calendar control enriches the experience of using different calendar types by incorporating various calendar views, including month, year, decade, and century views. These distinct views offer versatile options for interacting with dates, months, and years based on the specified calendar type.

Different calendar views in .NET MAUI Calendar control
Different calendar views in .NET MAUI Calendar control

You can change the calendar view using the View property in the SfCalendar. Refer to the following code example.

<calendar:SfCalendar x:Name="Calendar" Identifier="Hijri" View="Month"> 
</Calendar:SfCalendar>

Specifying the date value

When working with different calendar types in the .NET MAUI Calendar, you can assign a date value to its properties in two ways.

Generating a date

You can create a date value by declaring the calendar type while creating the date instance.

Refer to the following code example. Here, we’ve declared the date by specifying the calendar type as Hijri.

SfCalendar calendar = new SfCalendar();
Calendar hijriCalendar = new HijriCalendar();
DateTime date = new DateTime(1444, 12, 6, hijriCalendar);
calendar.SelectedDate = date;

Generating a date without calendar type

You can also create a date value without explicitly specifying the calendar type. In this case, the .NET MAUI Calendar will automatically convert and interpret the date value based on the specified local system’s calendar type.

Refer to the following code example. Here, we’ve used the Gregorian date, but the .NET MAUI Calendar control converts it to the corresponding Hijri calendar date.

SfCalendar calendar = new SfCalendar();
DateTime date = new DateTime(2023, 6, 24);
calendar.SelectedDate = date;
Specifying the date value in the .NET MAUI Calendar
Specifying the date value in the .NET MAUI Calendar

Specifying the flow direction

The .NET MAUI Calendar control automatically adjusts the flow direction based on the specified calendar type. This means that when you choose a calendar type with a right-to-left flow direction, such as in the Arabic calendar, the .NET MAUI Calendar control will automatically display the calendar elements in a right-to-left orientation.

The right-to-left supported calendar types in the .NET MAUI Calendar are:

  • Hijri
  • Persian
  • UmAlQura

Conclusion

Thanks for reading! In this blog, we have explored the various calendar types available in the Syncfusion .NET MAUI Calendar control and their versatile features. With this, you can enhance the experience of your global users.

Explore other features in the Calendar control in its documentation. Try out the .NET MAUI demos available on GitHub and share your feedback or ask questions in the comments section.

If you are not a Syncfusion customer, try our 30-day free trial to see how our components can enhance your productivity.

You can also contact us through our support forum, support portal, or feedback portal. We are always happy to assist you!

Related blogs

--

--

Jollen Moyani
Syncfusion

As a content editor at Syncfusion, I am passionate about technology and dedicated to staying up-to-date with the latest advancements and trends in the industry.