📜  persian datapicker - C# (1)

📅  最后修改于: 2023-12-03 15:18:18.210000             🧑  作者: Mango

Persian DatePicker - C#

Introduction

The Persian DatePicker is a powerful and easy-to-use library designed for C# programmers to work with Persian (Solar Hijri) dates in their applications. It allows users to select, manipulate, and format Persian dates seamlessly within their C# projects.

This library provides a wide range of functionalities, including conversion between Gregorian and Persian dates, formatting and parsing Persian dates, and displaying a calendar widget for easy date selection.

Key Features
  • Conversion between Gregorian and Persian dates:

    • Convert Persian dates to Gregorian dates and vice versa.
    • Retrieve the week number for a specific Persian date.
  • Formatting and parsing Persian dates:

    • Format Persian dates according to different patterns such as "yyyy/MM/dd" or "dd MMMM yyyy".
    • Parse Persian date strings and convert them to DateTime objects.
  • Calendar widget:

    • Display a calendar widget for selecting Persian dates with ease.
    • Customize the appearance and behavior of the calendar widget to fit your application's requirements.
  • Localization:

    • Localize the library to support different languages and cultures.
    • Translate day and month names into your desired language.
Installation

To start using the Persian DatePicker library in your C# project, you can install it via NuGet package manager or by downloading the source code from the GitHub repository.

Via NuGet Package Manager
  1. Open your project in Visual Studio.
  2. Right-click on your project in the Solution Explorer.
  3. Select "Manage NuGet Packages".
  4. Search for "PersianDatePicker" in the NuGet Package Manager.
  5. Click on the "Install" button to install the package into your project.
Via GitHub Repository
  1. Go to the Persian DatePicker GitHub repository.
  2. Clone or download the repository to your local machine.
  3. Add the library to your project's references.
Usage

Once the Persian DatePicker library is installed in your project, you can use its functionalities in your C# code as follows:

using PersianDatePicker; // Import the library namespace

class Program
{
    static void Main(string[] args)
    {
        // Convert between Gregorian and Persian dates
        DateTime gregorianDate = new DateTime(2023, 4, 15);
        PersianDate persianDate = PersianDateConverter.ToPersianDate(gregorianDate);
        Console.WriteLine($"Persian Date: {persianDate}");

        // Format and parse Persian dates
        string formattedDate = persianDate.ToString("yyyy/MM/dd");
        Console.WriteLine($"Formatted Date: {formattedDate}");

        PersianDate parsedDate = PersianDate.Parse("1400/01/01");
        Console.WriteLine($"Parsed Date: {parsedDate}");

        // Display a calendar widget
        PersianDatePickerWidget.Show();

        // Localize the library
        PersianDateLocalization.SetCulture("fa-IR");
        Console.WriteLine($"Localization Example: {persianDate.ToString("D")}");
    }
}

For more detailed usage examples and documentation, please refer to the official documentation.

Conclusion

The Persian DatePicker library provides C# developers with a convenient way to handle Persian dates in their applications. It offers a wide range of functionalities, such as conversion between Gregorian and Persian dates, formatting and parsing Persian dates, and displaying a calendar widget. By using this library, programmers can easily incorporate Persian date functionality into their C# projects and enhance user experience.