Files
moadiran/Shared/ExMethod.cs
mmrbnjd 3ca7f9deb0 ...
2024-05-16 23:40:32 +03:30

36 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Shared
{
public static class ExMethod
{
public static string ShamciToFormatShamciinFront(this string str)
{
if (string.IsNullOrEmpty(str)) return "";
return str.Substring(0, 4) + "/" + str.Substring(4, 2) + "/" + str.Substring(6, 2);
}
public static string ConvertMiladiToShamsiinFront(this DateTime date)
{
PersianCalendar PersianCal = new PersianCalendar();
return PersianCal.GetYear(date).ToString("0000") +
PersianCal.GetMonth(date).ToString("00") +
PersianCal.GetDayOfMonth(date).ToString("00")
;
}
public static string GetEnumDisplayName(this Enum enumType)
{
return enumType.GetType().GetMember(enumType.ToString())
.First()
.GetCustomAttribute<DisplayAttribute>()
.Name;
}
}
}