Skip to content

Commit

Permalink
Add XML documentation and generate files
Browse files Browse the repository at this point in the history
* **PrsianDate/PersianDate.csproj**
  - Add `<GenerateDocumentationFile>true</GenerateDocumentationFile>` to generate XML documentation.
  - Add `<IncludeSymbols>true</IncludeSymbols>` to generate symbol files.
  - Add `<ReadmeFile>README.md</ReadmeFile>` to include the readme file in the NuGet package.

* **PrsianDate/PersianDateShamsi.cs**
  - Add XML documentation comments to all public methods and properties.
  - Add `<summary>` tags to describe the purpose of each method.
  - Add `<param>` tags to describe each parameter.
  - Add `<returns>` tags to describe the return value.

* **PrsianDate/ToShamsi.cs**
  - Add XML documentation comments to all public methods and properties.
  - Add `<summary>` tags to describe the purpose of each method.
  - Add `<param>` tags to describe each parameter.
  - Add `<returns>` tags to describe the return value.
  • Loading branch information
hootanht committed Sep 12, 2024
1 parent 1449fa8 commit 53fdc0c
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 34 deletions.
3 changes: 3 additions & 0 deletions PrsianDate/PersianDate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
<Nullable>enable</Nullable>
<PackageSource>https://api.nuget.org/v3/index.json</PackageSource>
<PublishProfile>nuget</PublishProfile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IncludeSymbols>true</IncludeSymbols>
<ReadmeFile>README.md</ReadmeFile>
</PropertyGroup>

<ItemGroup>
Expand Down
84 changes: 52 additions & 32 deletions PrsianDate/PersianDateShamsi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@

namespace PersianDate
{
/// <summary>
/// Provides methods to convert Gregorian dates to Persian (Shamsi) dates.
/// </summary>
public class PersianDateShamsi
{
PersianCalendar persianCalendar;
private readonly PersianCalendar persianCalendar;

/// <summary>
/// Initializes a new instance of the <see cref="PersianDateShamsi"/> class.
/// </summary>
public PersianDateShamsi()
{
persianCalendar = new PersianCalendar();
}
/// <returns></returns>

/// <summary>
/// Gets the Shamsi year from the specified Gregorian date.
/// </summary>
/// <param name="dateTime">The Gregorian date.</param>
/// <returns>The Shamsi year, or null if the input is null or out of range.</returns>
public int? GetShamsiYear(DateTime? dateTime)
{
if (!dateTime.HasValue)
Expand All @@ -25,20 +37,22 @@ public PersianDateShamsi()
return null;
}
}

/// <summary>
/// Get Short Shamsi Year From Miladi Year In String
/// Gets the short Shamsi year from the specified Gregorian date as a string.
/// </summary>
/// <param name="dateTime">Enter The Jalali DateTime</param>
/// <returns></returns>
/// <param name="dateTime">The Gregorian date.</param>
/// <returns>The short Shamsi year as a string, or null if the input is null.</returns>
public string? GetShortShamsiYear(DateTime? dateTime)
{
return dateTime?.ToString("yy", CultureInfo.CreateSpecificCulture("fa"));
}

/// <summary>
/// Get Shamsi Year From Miladi Year In String
/// Gets the Shamsi year from the specified Gregorian date as a string.
/// </summary>
/// <param name="dateTime">Enter The Jalali DateTime</param>
/// <returns></returns>
/// <param name="dateTime">The Gregorian date.</param>
/// <returns>The Shamsi year as a string, or null if the input is null or out of range.</returns>
public string? GetShamsiYearToString(DateTime? dateTime)
{
if (!dateTime.HasValue)
Expand All @@ -55,74 +69,80 @@ public PersianDateShamsi()
}

/// <summary>
/// Get Shamsi Month From Miladi Month
/// Gets the Shamsi month from the specified Gregorian date.
/// </summary>
/// <param name="dateTime">Enter The Jalali DateTime</param>
/// <param name="dateTime">The Gregorian date.</param>
/// <returns>The Shamsi month, or null if the input is null.</returns>
public int? GetShamsiMonth(DateTime? dateTime)
{
return dateTime.HasValue ? persianCalendar.GetMonth(dateTime.Value) : null;
}

/// <summary>
/// Get Shamsi Month Number From Miladi Month In String
/// Gets the Shamsi month number from the specified Gregorian date as a string.
/// </summary>
/// <param name="dateTime">Enter The Jalali DateTime</param>
/// <returns></returns>
/// <param name="dateTime">The Gregorian date.</param>
/// <returns>The Shamsi month number as a string.</returns>
public string GetShamsiMonthString(DateTime dateTime)
{
return persianCalendar.GetMonth(dateTime).ToString("00");
}

/// <summary>
/// Get Shamsi Month From Miladi Month Number
/// Gets the Shamsi month number from the specified Gregorian date.
/// </summary>
/// <param name="dateTime">Enter The Jalali DateTime</param>
/// <returns></returns>
/// <param name="dateTime">The Gregorian date.</param>
/// <returns>The Shamsi month number, or null if the input is null.</returns>
public int? GetShamsiMonthNumber(DateTime? dateTime)
{
return dateTime.HasValue ? persianCalendar.GetMonth(dateTime.Value) : null;
}

/// <summary>
/// Get Shamsi Month Name From Miladi Month
/// Gets the Shamsi month name from the specified Gregorian date.
/// </summary>
/// <param name="dateTime">Enter The Jalali DateTime</param>
/// <returns></returns>
/// <param name="dateTime">The Gregorian date.</param>
/// <returns>The Shamsi month name, or null if the input is null.</returns>
public string? GetShamsiMonthName(DateTime? dateTime)
{
return dateTime?.ToString("MMMM", CultureInfo.CreateSpecificCulture("fa"));
}


/// <summary>
/// Get Shamsi Day From Miladi Month
/// Gets the Shamsi day from the specified Gregorian date.
/// </summary>
/// <param name="dateTime">Enter The Jalali DateTime</param>
/// <returns></returns>
/// <param name="dateTime">The Gregorian date.</param>
/// <returns>The Shamsi day, or null if the input is null.</returns>
public int? GetShamsiDay(DateTime? dateTime)
{
return dateTime.HasValue ? persianCalendar.GetDayOfMonth(dateTime.Value) : null;
}

/// <summary>
/// Get Shamsi Day From Miladi Month In String
/// Gets the Shamsi day from the specified Gregorian date as a string.
/// </summary>
/// <param name="dateTime">Enter The Jalali DateTime</param>
/// <returns></returns>
/// <param name="dateTime">The Gregorian date.</param>
/// <returns>The Shamsi day as a string, or null if the input is null.</returns>
public string? GetShamsiDayString(DateTime? dateTime)
{
return dateTime.HasValue ? persianCalendar.GetDayOfMonth(dateTime.Value).ToString("00") : null;
}

/// <summary>
/// Get Shamsi Day Name From Miladi Month
/// Gets the Shamsi day name from the specified Gregorian date.
/// </summary>
/// <param name="dateTime">Enter The Jalali DateTime</param>
/// <returns></returns>
/// <param name="dateTime">The Gregorian date.</param>
/// <returns>The Shamsi day name, or null if the input is null.</returns>
public string? GetShamsiDayName(DateTime? dateTime)
{
return dateTime?.ToString("dddd", CultureInfo.CreateSpecificCulture("fa"));
}

/// <summary>
/// Get Shamsi Day ShortName From Miladi Month
/// Gets the short Shamsi day name from the specified Gregorian date.
/// </summary>
/// <param name="dateTime">Enter The Jalali DateTime</param>
/// <returns></returns>
/// <param name="dateTime">The Gregorian date.</param>
/// <returns>The short Shamsi day name, or null if the input is null.</returns>
public string? GetShamsiDayShortName(DateTime? dateTime)
{
return (dateTime?.ToString("dddd", CultureInfo.CreateSpecificCulture("fa")))?[..1];
Expand Down
9 changes: 7 additions & 2 deletions PrsianDate/ToShamsi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace PersianDate
{
/// <summary>
/// Provides extension methods to convert Gregorian dates to Persian (Shamsi) dates.
/// </summary>
public static class ToShamsi
{
/// <summary>
Expand All @@ -17,11 +20,12 @@ public static class ToShamsi
var persianDateShamsi = new PersianDateShamsi();
return persianDateShamsi.GetShamsiYearToString(dateTime) + "/" + persianDateShamsi.GetShamsiMonthString(dateTime.Value) + "/" + persianDateShamsi.GetShamsiDayString(dateTime.Value);
}

/// <summary>
/// Get Short Shamsi Date From Miladi Year
/// </summary>
/// <param name="dateTime">Enter The Jalali DateTime</param>
/// <returns></returns>
/// <returns>A string representing the short Shamsi date or null if the input is null.</returns>
public static string? ToShortShamsiDate(this DateTime? dateTime)
{
if (!dateTime.HasValue)
Expand All @@ -30,11 +34,12 @@ public static class ToShamsi
var persianDateShamsi = new PersianDateShamsi();
return persianDateShamsi.GetShortShamsiYear(dateTime) + "/" + persianDateShamsi.GetShamsiMonthString(dateTime.Value) + "/" + persianDateShamsi.GetShamsiDayString(dateTime.Value);
}

/// <summary>
/// Get Long Shamsi Date From Miladi Year
/// </summary>
/// <param name="dateTime">Enter The Jalali DateTime</param>
/// <returns></returns>
/// <returns>A string representing the long Shamsi date or null if the input is null.</returns>
public static string? ToLongShamsiDate(this DateTime? dateTime)
{
if (!dateTime.HasValue)
Expand Down

0 comments on commit 53fdc0c

Please sign in to comment.