mriman
پنج شنبه 30 اردیبهشت 1395, 11:26 صبح
سلام برهمه عزیزان MVC کار!
من در model کلاسی برای ساخت extention ایجاد کرده ام و در آن کد زیر را نوشتم:
public static class myExtention
}
public static string ToPersian( this DateTime dt )
{
PersianCalendar pc = new PersianCalendar();
int year = pc.GetYear(dt);
int month = pc.GetMonth(dt);
int day = pc.GetDayOfMonth(dt);
int hour = pc.GetHour(dt);
int min = pc.GetMinute(dt);
DateTime persianDateTime = new DateTime(year, month, day, hour, min, 0);
return persianDateTime.ToString();
}
زماانی که میخوام نتیجه رو در خروجی مشاهده کنم خطای زیر را میده!!!! خواهش میکنم کمکم کنید. در فیلم آموزشی که من دیدم بدون هیچ مشکلی اجرا میشه اما رو سیستم من گیر میده!!چه کنم؟؟
Year, Month, and Day parameters describe an un-representable DateTime.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Year, Month, and Day parameters describe an un-representable DateTime.
Source Error:
Line 37:
Line 38:
Line 39: DateTime persianDateTime = new DateTime(year, month, day, hour, min, 0);
Line 40:
Line 41: return persianDateTime.ToString();
من در model کلاسی برای ساخت extention ایجاد کرده ام و در آن کد زیر را نوشتم:
public static class myExtention
}
public static string ToPersian( this DateTime dt )
{
PersianCalendar pc = new PersianCalendar();
int year = pc.GetYear(dt);
int month = pc.GetMonth(dt);
int day = pc.GetDayOfMonth(dt);
int hour = pc.GetHour(dt);
int min = pc.GetMinute(dt);
DateTime persianDateTime = new DateTime(year, month, day, hour, min, 0);
return persianDateTime.ToString();
}
زماانی که میخوام نتیجه رو در خروجی مشاهده کنم خطای زیر را میده!!!! خواهش میکنم کمکم کنید. در فیلم آموزشی که من دیدم بدون هیچ مشکلی اجرا میشه اما رو سیستم من گیر میده!!چه کنم؟؟
Year, Month, and Day parameters describe an un-representable DateTime.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Year, Month, and Day parameters describe an un-representable DateTime.
Source Error:
Line 37:
Line 38:
Line 39: DateTime persianDateTime = new DateTime(year, month, day, hour, min, 0);
Line 40:
Line 41: return persianDateTime.ToString();