Skip to content

gregorian to shamsi added #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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')}";
}
}
}