Пример #1
0
        private static bool CheckIsHoliday(DateTime date)
        {
            PersianCalendar pc     = new PersianCalendar();
            bool            result = false;

            //Todo: every year must be checked
            // -1 is HijriAdjustment for fixing right day
            try
            {
                IslamicDay hijriNow         = IslamicDateUtils.GregorianToIslamicDay(date.Year, date.Month, date.Day - 1);
                JObject    oo               = JObject.Parse(PersianToolkit.Properties.Resources.events);
                string[]   getPersianEvents = oo["Persian Calendar"].Where(x => x != null && x.SelectToken("day").ToString() == pc.GetDayOfMonth(date).ToString() &&
                                                                           x.SelectToken("month").ToString() == pc.GetMonth(date).ToString() && x.SelectToken("type").ToString() == "Iran")
                                              .Select(m => (string)m.SelectToken("holiday")).ToArray();

                string[] getHijriEvents = oo["Hijri Calendar"].Where(x => x != null && x.SelectToken("day").ToString() == hijriNow.Day.ToString() &&
                                                                     x.SelectToken("month").ToString() == hijriNow.Month.ToString() && x.SelectToken("type").ToString() == "Islamic Iran")
                                          .Select(m => (string)m.SelectToken("holiday")).ToArray();

                if (string.Join(", ", getPersianEvents).Contains("True") || string.Join(", ", getHijriEvents).Contains("True"))
                {
                    result = true;
                }
                else
                {
                    result = false;
                }
            }
            catch
            {
            }
            return(result);
        }
Пример #2
0
        /// <summary>

        /// Equals

        /// </summary>

        /// <param name="obj"></param>

        /// <returns></returns>

        public override bool Equals(object obj)

        {
            IslamicDay day = obj as IslamicDay;

            if (day == null)
            {
                return(false);
            }

            return(Year == day.Year &&

                   Month == day.Month &&

                   Day == day.Day);
        }