Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions SadrTools.CommonTools/Utility/DateMethods.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
namespace SadrTools.CommonTools.Utility
using System;
using System.Globalization;
namespace SadrTools.CommonTools.Utility
{
public static class DateMethods
{

/// <summary>
/// تبدیل به تاریخ شمسی
/// </summary>
/// <param name="date">تاریخ</param>
/// <param name="seprator">جدا کننده</param>
/// <returns>تاریخ شمسی</returns>
public static string ToPersianDate(DateTime date, char seprator = '/')
{
PersianCalendar pc = new PersianCalendar();
int year = pc.GetYear(date);
int month = pc.GetMonth(date);
int day = pc.GetDayOfMonth(date);
return $"{year}{seprator}{month.ToString().PadLeft(2, '0')}{seprator}{day.ToString().PadLeft(2, '0')}";
}
}
}