示例#1
0
        /// <summary>
        /// get farsi mah number
        /// </summary>
        /// <param name="selectedYear"></param>
        /// <param name="selectedMonth"></param>
        /// <param name="selectedDay"></param>
        /// <returns></returns>
        internal static int?SaalNum(int?selectedYear, int?selectedMonth, int?selectedDay)
        {
            var shamsi = ConvertDate.ToShamsiDate(selectedYear, selectedMonth, selectedDay);

            if (shamsi == null)
            {
                return(null);
            }

            return(shamsi.Saal);
        }
示例#2
0
        public static Dictionary <String, int> GetAllFarsiMonths()
        {
            Dictionary <String, int> ht = new Dictionary <String, int>();

            for (int i = 1; i <= 12; i++)
            {
                ht.Add(ConvertDate.MapFarsiMonthNumToName(i), i);
            }
            //ht.Add(string.Format("{1} - {0}",Convert_Date.Map_FarsiMonthNum_ToName(i),i), i);

            return(ht);
        }
        /// <summary>
        /// this constructor uses PersianCalendar and store its method returned values in a more friendler structor
        /// and properties of this class
        /// </summary>
        /// <param name="date"></param>
        internal ShamsiDate(DateTime date)
        {
            EquivalentGoergianDate = date;
            var pDate = new System.Globalization.PersianCalendar();

            Saal     = pDate.GetYear(date);
            Mah      = pDate.GetMonth(date);
            RoozeMah = pDate.GetDayOfMonth(date);
            //time
            Saat     = pDate.GetHour(date);
            Daghighe = pDate.GetMinute(date);
            Saniyeh  = pDate.GetSecond(date);

            RoozeHafteh = ConvertDate.MapWeekDayToNum(pDate.GetDayOfWeek(date));
        }
        internal ShamsiDate(int saal, int mah, int rooz)
        {
            Saal     = saal;
            Mah      = mah;
            RoozeMah = rooz;

            var pDate = new System.Globalization.PersianCalendar();

            EquivalentGoergianDate = pDate.ToDateTime(saal, mah, rooz, 0, 0, 0, 0);

            Saat     = pDate.GetHour(EquivalentGoergianDate);
            Daghighe = pDate.GetMinute(EquivalentGoergianDate);
            Saniyeh  = pDate.GetSecond(EquivalentGoergianDate);

            RoozeHafteh = ConvertDate.MapWeekDayToNum(pDate.GetDayOfWeek(EquivalentGoergianDate));
        }
示例#5
0
 /// <summary>
 /// return only the year, used for example in the footer and copyright in one shot
 /// </summary>
 /// <param name="dateTime"></param>
 /// <returns></returns>
 public static int SaalNum(DateTime dateTime)
 {
     return(ConvertDate.ToShamsiDate(dateTime).Saal);
 }
示例#6
0
 /// <summary>
 /// روزه ماه
 /// </summary>
 /// <param name="dateTime"></param>
 /// <returns></returns>
 public static int RoozNum(DateTime dateTime)
 {
     return(ConvertDate.ToShamsiDate(dateTime).RoozeMah);
 }
示例#7
0
 /// <summary>
 /// return only the month , used for example in the footer and copyright in one shot
 /// </summary>
 /// <param name="dateTime"></param>
 /// <returns></returns>
 public static int MahNum(DateTime dateTime)
 {
     return(ConvertDate.ToShamsiDate(dateTime).Mah);
 }