public void Day_Index_Has_Correct_Mapping()
 {
     Assert.AreEqual(0, PersianDateTimeFormatInfo.GetDayIndex(DayOfWeek.Saturday));
     Assert.AreEqual(1, PersianDateTimeFormatInfo.GetDayIndex(DayOfWeek.Sunday));
     Assert.AreEqual(2, PersianDateTimeFormatInfo.GetDayIndex(DayOfWeek.Monday));
     Assert.AreEqual(3, PersianDateTimeFormatInfo.GetDayIndex(DayOfWeek.Tuesday));
     Assert.AreEqual(4, PersianDateTimeFormatInfo.GetDayIndex(DayOfWeek.Wednesday));
     Assert.AreEqual(5, PersianDateTimeFormatInfo.GetDayIndex(DayOfWeek.Thursday));
     Assert.AreEqual(6, PersianDateTimeFormatInfo.GetDayIndex(DayOfWeek.Friday));
 }
Example #2
0
        /// <summary>
        /// Returns the day of week based on calendar.
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="calendar"></param>
        /// <returns></returns>
        public static int GetDayOfWeek(DateTime dt, Calendar calendar)
        {
            var calendarType = calendar.GetType();

            if (calendarType == typeof(PersianCalendar) ||
                calendarType == typeof(System.Globalization.PersianCalendar))
            {
                return(PersianDateTimeFormatInfo.GetDayIndex(dt.DayOfWeek));
            }

            return((int)dt.DayOfWeek);
        }
        protected internal int GetFirstDayOfWeek(DateTime date)
        {
            if (CultureHelper.IsFarsiCulture)
            {
                return(PersianDateTimeFormatInfo.GetDayIndex(date.DayOfWeek));
            }

            if (CultureHelper.IsArabicCulture)
            {
                return((int)date.DayOfWeek);
            }

            return((int)date.DayOfWeek);
        }