From 53fdc0c6f06662600fe86fb17e17c1717739fb85 Mon Sep 17 00:00:00 2001 From: Hootan Hemmati Date: Thu, 12 Sep 2024 11:34:35 +0330 Subject: [PATCH] Add XML documentation and generate files * **PrsianDate/PersianDate.csproj** - Add `true` to generate XML documentation. - Add `true` to generate symbol files. - Add `README.md` to include the readme file in the NuGet package. * **PrsianDate/PersianDateShamsi.cs** - Add XML documentation comments to all public methods and properties. - Add `` tags to describe the purpose of each method. - Add `` tags to describe each parameter. - Add `` tags to describe the return value. * **PrsianDate/ToShamsi.cs** - Add XML documentation comments to all public methods and properties. - Add `` tags to describe the purpose of each method. - Add `` tags to describe each parameter. - Add `` tags to describe the return value. --- PrsianDate/PersianDate.csproj | 3 ++ PrsianDate/PersianDateShamsi.cs | 84 ++++++++++++++++++++------------- PrsianDate/ToShamsi.cs | 9 +++- 3 files changed, 62 insertions(+), 34 deletions(-) diff --git a/PrsianDate/PersianDate.csproj b/PrsianDate/PersianDate.csproj index 60d0c93..9ba6c68 100644 --- a/PrsianDate/PersianDate.csproj +++ b/PrsianDate/PersianDate.csproj @@ -22,6 +22,9 @@ enable https://api.nuget.org/v3/index.json nuget + true + true + README.md diff --git a/PrsianDate/PersianDateShamsi.cs b/PrsianDate/PersianDateShamsi.cs index 52db93f..90b42f8 100644 --- a/PrsianDate/PersianDateShamsi.cs +++ b/PrsianDate/PersianDateShamsi.cs @@ -3,14 +3,26 @@ namespace PersianDate { + /// + /// Provides methods to convert Gregorian dates to Persian (Shamsi) dates. + /// public class PersianDateShamsi { - PersianCalendar persianCalendar; + private readonly PersianCalendar persianCalendar; + + /// + /// Initializes a new instance of the class. + /// public PersianDateShamsi() { persianCalendar = new PersianCalendar(); } - /// + + /// + /// Gets the Shamsi year from the specified Gregorian date. + /// + /// The Gregorian date. + /// The Shamsi year, or null if the input is null or out of range. public int? GetShamsiYear(DateTime? dateTime) { if (!dateTime.HasValue) @@ -25,20 +37,22 @@ public PersianDateShamsi() return null; } } + /// - /// Get Short Shamsi Year From Miladi Year In String + /// Gets the short Shamsi year from the specified Gregorian date as a string. /// - /// Enter The Jalali DateTime - /// + /// The Gregorian date. + /// The short Shamsi year as a string, or null if the input is null. public string? GetShortShamsiYear(DateTime? dateTime) { return dateTime?.ToString("yy", CultureInfo.CreateSpecificCulture("fa")); } + /// - /// Get Shamsi Year From Miladi Year In String + /// Gets the Shamsi year from the specified Gregorian date as a string. /// - /// Enter The Jalali DateTime - /// + /// The Gregorian date. + /// The Shamsi year as a string, or null if the input is null or out of range. public string? GetShamsiYearToString(DateTime? dateTime) { if (!dateTime.HasValue) @@ -55,74 +69,80 @@ public PersianDateShamsi() } /// - /// Get Shamsi Month From Miladi Month + /// Gets the Shamsi month from the specified Gregorian date. /// - /// Enter The Jalali DateTime + /// The Gregorian date. + /// The Shamsi month, or null if the input is null. public int? GetShamsiMonth(DateTime? dateTime) { return dateTime.HasValue ? persianCalendar.GetMonth(dateTime.Value) : null; } + /// - /// Get Shamsi Month Number From Miladi Month In String + /// Gets the Shamsi month number from the specified Gregorian date as a string. /// - /// Enter The Jalali DateTime - /// + /// The Gregorian date. + /// The Shamsi month number as a string. public string GetShamsiMonthString(DateTime dateTime) { return persianCalendar.GetMonth(dateTime).ToString("00"); } + /// - /// Get Shamsi Month From Miladi Month Number + /// Gets the Shamsi month number from the specified Gregorian date. /// - /// Enter The Jalali DateTime - /// + /// The Gregorian date. + /// The Shamsi month number, or null if the input is null. public int? GetShamsiMonthNumber(DateTime? dateTime) { return dateTime.HasValue ? persianCalendar.GetMonth(dateTime.Value) : null; } + /// - /// Get Shamsi Month Name From Miladi Month + /// Gets the Shamsi month name from the specified Gregorian date. /// - /// Enter The Jalali DateTime - /// + /// The Gregorian date. + /// The Shamsi month name, or null if the input is null. public string? GetShamsiMonthName(DateTime? dateTime) { return dateTime?.ToString("MMMM", CultureInfo.CreateSpecificCulture("fa")); } - /// - /// Get Shamsi Day From Miladi Month + /// Gets the Shamsi day from the specified Gregorian date. /// - /// Enter The Jalali DateTime - /// + /// The Gregorian date. + /// The Shamsi day, or null if the input is null. public int? GetShamsiDay(DateTime? dateTime) { return dateTime.HasValue ? persianCalendar.GetDayOfMonth(dateTime.Value) : null; } + /// - /// Get Shamsi Day From Miladi Month In String + /// Gets the Shamsi day from the specified Gregorian date as a string. /// - /// Enter The Jalali DateTime - /// + /// The Gregorian date. + /// The Shamsi day as a string, or null if the input is null. public string? GetShamsiDayString(DateTime? dateTime) { return dateTime.HasValue ? persianCalendar.GetDayOfMonth(dateTime.Value).ToString("00") : null; } + /// - /// Get Shamsi Day Name From Miladi Month + /// Gets the Shamsi day name from the specified Gregorian date. /// - /// Enter The Jalali DateTime - /// + /// The Gregorian date. + /// The Shamsi day name, or null if the input is null. public string? GetShamsiDayName(DateTime? dateTime) { return dateTime?.ToString("dddd", CultureInfo.CreateSpecificCulture("fa")); } + /// - /// Get Shamsi Day ShortName From Miladi Month + /// Gets the short Shamsi day name from the specified Gregorian date. /// - /// Enter The Jalali DateTime - /// + /// The Gregorian date. + /// The short Shamsi day name, or null if the input is null. public string? GetShamsiDayShortName(DateTime? dateTime) { return (dateTime?.ToString("dddd", CultureInfo.CreateSpecificCulture("fa")))?[..1]; diff --git a/PrsianDate/ToShamsi.cs b/PrsianDate/ToShamsi.cs index d1be630..7c2d577 100644 --- a/PrsianDate/ToShamsi.cs +++ b/PrsianDate/ToShamsi.cs @@ -2,6 +2,9 @@ namespace PersianDate { + /// + /// Provides extension methods to convert Gregorian dates to Persian (Shamsi) dates. + /// public static class ToShamsi { /// @@ -17,11 +20,12 @@ public static class ToShamsi var persianDateShamsi = new PersianDateShamsi(); return persianDateShamsi.GetShamsiYearToString(dateTime) + "/" + persianDateShamsi.GetShamsiMonthString(dateTime.Value) + "/" + persianDateShamsi.GetShamsiDayString(dateTime.Value); } + /// /// Get Short Shamsi Date From Miladi Year /// /// Enter The Jalali DateTime - /// + /// A string representing the short Shamsi date or null if the input is null. public static string? ToShortShamsiDate(this DateTime? dateTime) { if (!dateTime.HasValue) @@ -30,11 +34,12 @@ public static class ToShamsi var persianDateShamsi = new PersianDateShamsi(); return persianDateShamsi.GetShortShamsiYear(dateTime) + "/" + persianDateShamsi.GetShamsiMonthString(dateTime.Value) + "/" + persianDateShamsi.GetShamsiDayString(dateTime.Value); } + /// /// Get Long Shamsi Date From Miladi Year /// /// Enter The Jalali DateTime - /// + /// A string representing the long Shamsi date or null if the input is null. public static string? ToLongShamsiDate(this DateTime? dateTime) { if (!dateTime.HasValue)