Files
moadiran/Shared/ExMethod.cs

36 lines
1.1 KiB
C#
Raw Normal View History

2024-05-14 14:58:25 +03:30
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
2024-05-16 23:40:32 +03:30
using System.Globalization;
2024-05-14 14:58:25 +03:30
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Shared
{
public static class ExMethod
{
2024-05-16 23:40:32 +03:30
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")
;
}
2024-05-14 14:58:25 +03:30
public static string GetEnumDisplayName(this Enum enumType)
{
return enumType.GetType().GetMember(enumType.ToString())
.First()
.GetCustomAttribute<DisplayAttribute>()
.Name;
}
}
}