public static int EncodeTime(DateTime d)
		{
			GregorianCalendar calendar = new GregorianCalendar();

			int millisInDay =
				(int)(calendar.GetHour(d) * 3600000 +
				calendar.GetMinute(d) * 60000 +
				calendar.GetSecond(d) * 1000 +
				calendar.GetMilliseconds(d)) * 10;

			return millisInDay;
		}
 public DateTime ShamsiTogregorian(DateTime date)
 {
     PersianCalendar pc = new PersianCalendar();
     GregorianCalendar gcalendar = new GregorianCalendar();
     DateTime eDate = pc.ToDateTime(
            gcalendar.GetYear(date),
            gcalendar.GetMonth(date),
            gcalendar.GetDayOfMonth(date),
            gcalendar.GetHour(date),
            gcalendar.GetMinute(date),
            gcalendar.GetSecond(date), 0);
     return eDate;
 }
 public static TimeSpan DateTimeToTimeSpan(DateTime d)
 {
     GregorianCalendar calendar = new GregorianCalendar();
     return new TimeSpan(0, calendar.GetHour(d), calendar.GetMinute(d), calendar.GetSecond(d), (int)calendar.GetMilliseconds(d));
 }
        public static DateTime GetChristianDateTime(string _Fdate)
        {
            _Fdate = _Fdate.Trim().Replace(':', '/').Replace('-', '/').Replace(' ', '/');
            var dateArray = new string[6];
            if (_Fdate.Length <= 10)
            {
                _Fdate = _Fdate + "/0/0/0";
            }
            dateArray = _Fdate.Split('/');

            PersianCalendar pcalendar = new PersianCalendar();
            GregorianCalendar gcalendar = new GregorianCalendar();
            DateTime eDate = pcalendar.ToDateTime(
                    gcalendar.GetYear(new DateTime(int.Parse(dateArray[0]), 1, 1)),
                    gcalendar.GetMonth(new DateTime(1395, int.Parse(dateArray[1]), 1)),
                    gcalendar.GetDayOfMonth(new DateTime(1395, 1, int.Parse(dateArray[2]))),
                    gcalendar.GetHour(new DateTime(1395, 1, 1, int.Parse(dateArray[3]), 0, 0)),
                    gcalendar.GetMinute(new DateTime(1395, 1, 1, 1, int.Parse(dateArray[4]), 0)),
                    gcalendar.GetSecond(new DateTime(1395, 1, 1, 1, 1, int.Parse(dateArray[5]))), 0);
            return eDate;
        }