/// <summary> /// Determines if the two given DateTime object refer to the same day. /// NOTE: This function was created for the situation where the time factor /// of the given DateTime objects is not a factor in determining if they are the same; /// if they refer to the same date, the function returns true. /// </summary> /// <param name="firstDate"></param> /// <param name="secondDate"></param> /// <returns></returns> public static bool IsSameday(this DateTime firstDate, DateTime secondDate) { return(firstDate.Date == secondDate.Date || (HebrewCalendar.GetYear(firstDate) == HebrewCalendar.GetYear(secondDate) && HebrewCalendar.GetMonth(firstDate) == HebrewCalendar.GetMonth(secondDate) && HebrewCalendar.GetDayOfMonth(firstDate) == HebrewCalendar.GetDayOfMonth(secondDate))); }
private void SetHebAnnualsOnDate(DateTime date, ref int[] ids, ref bool[] isAnnuals, ref string[] events) { HebrewCalendar hebDate = new HebrewCalendar(); int month = hebDate.GetMonth(date), day = hebDate.GetDayOfMonth(date); OleDbCommand datacommand = new OleDbCommand(); datacommand.Connection = dataConnection; datacommand.CommandText = "SELECT *" + "FROM tblAnnuals " + "WHERE annualGregorian = false AND annualMonth= " + month + " AND annualDay = " + day + " " + "ORDER BY annualID"; OleDbDataReader dataReader = datacommand.ExecuteReader(); while (dataReader.Read()) { int annualID = dataReader.GetInt32(0); string annualName = dataReader.GetString(2); if (index == ids.Length) { ResizeArrays(ref ids, ref events, ref isAnnuals, ids.Length + 1); } ids[index] = annualID; isAnnuals[index] = true; events[index++] = annualName; } dataReader.Close(); }
public static string GetHebrewDate(DateTime gregorianDate) { Calendar HebCal = new HebrewCalendar(); string hebrewDate = $"{HebCal.GetYear(gregorianDate)}-{HebCal.GetMonth(gregorianDate)}-{HebCal.GetDayOfMonth(gregorianDate)}"; return(hebrewDate); }
public void Can_convert_Gregorian_date_to_Jewish_Date() { var dateTime = new DateTime(2010, 4, 15, gregorianCalendar); Assert.That(hebrewCalendar.GetYear(dateTime), Is.EqualTo(5770)); Assert.That(hebrewCalendar.GetMonth(dateTime), Is.EqualTo(8)); Assert.That(hebrewCalendar.GetDayOfMonth(dateTime), Is.EqualTo(1)); }
///<summary>Creates a Hebrew date from an English one.</summary> ///<param name="englishDate">The English date to convert.</param> public HebrewDate(DateTime englishDate) { date = englishDate.Date; hebrewYear = calendar.GetYear(date); hebrewMonth = CalendarExtensions.ToHebrewMonth(hebrewYear, calendar.GetMonth(date)); hebrewDay = calendar.GetDayOfMonth(englishDate); }
/// <summary> /// متد تبديل تاريخ ميلادي به هبري /// </summary> public void MiladiToHebrew() { HebrewCalendar hb = new HebrewCalendar(); DateTime dt = new DateTime(year: Year, month: Month, day: Day); string result = $"Miladi To Hebrew:{ hb.GetYear(dt).ToString("0000/") } { hb.GetMonth(dt).ToString("00/") } { hb.GetDayOfMonth(dt).ToString("00") }"; System.Console.Write(result); }
public static void Main() { StreamWriter output = new StreamWriter("HebrewCalendarInfo.txt"); // Make the Hebrew Calendar the current calendar and // Hebrew (Israel) the current thread culture. HebrewCalendar hc = new HebrewCalendar(); CultureInfo culture = CultureInfo.CreateSpecificCulture("he-IL"); culture.DateTimeFormat.Calendar = hc; Thread.CurrentThread.CurrentCulture = culture; output.WriteLine("{0} Information:\n", GetCalendarName(culture.DateTimeFormat.Calendar)); // Get the calendar range expressed in both Hebrew calendar and // Gregorian calendar dates. output.WriteLine("Start Date: {0} ", hc.MinSupportedDateTime); culture.DateTimeFormat.Calendar = culture.Calendar; output.WriteLine(" ({0} Gregorian)\n", hc.MinSupportedDateTime); culture.DateTimeFormat.Calendar = hc; output.WriteLine("End Date: {0} ", hc.MaxSupportedDateTime); culture.DateTimeFormat.Calendar = culture.Calendar; output.WriteLine(" ({0} Gregorian)\n", hc.MaxSupportedDateTime); culture.DateTimeFormat.Calendar = hc; // Get the year in the Hebrew calendar that corresponds to 1/1/2012 // and display information about it. DateTime startOfYear = new DateTime(2012, 1, 1); output.WriteLine("Days in the Year {0}: {1}\n", hc.GetYear(startOfYear), hc.GetDaysInYear(hc.GetYear(startOfYear))); output.WriteLine("Days in Each Month of {0}:\n", hc.GetYear(startOfYear)); output.WriteLine("Month Days Month Name"); // Change start of year to first day of first month startOfYear = hc.ToDateTime(hc.GetYear(startOfYear), 1, 1, 0, 0, 0, 0); DateTime startOfMonth = startOfYear; for (int ctr = 1; ctr <= hc.GetMonthsInYear(hc.GetYear(startOfYear)); ctr++) { output.Write(" {0,2}", ctr); output.WriteLine("{0,12}{1,15:MMM}", hc.GetDaysInMonth(hc.GetYear(startOfMonth), hc.GetMonth(startOfMonth)), startOfMonth); startOfMonth = hc.AddMonths(startOfMonth, 1); } output.Close(); }
public JewishDate(DateTime date) { var jewishCulture = CreateJewishCulture(); HebrewCalendar calendar = (HebrewCalendar)jewishCulture.DateTimeFormat.Calendar; // convert gregorian date to jewish date _month = calendar.GetMonth(date); _year = calendar.GetYear(date); _day = calendar.GetDayOfMonth(date); _monthLabel = GetHebrewMonth(_month, calendar.IsLeapYear(_year)); _isLeap = calendar.IsLeapYear(_year); }
/// <summary> /// מחשב האם התאריך בטווח התאריכים בהתחשב בנתוני לוח עברי : שנה מעוברת ,שנים מלאות ,חסרות וכסדרן /// </summary> /// <param name="value">date to check(today)</param> /// <param name="date">date of event</param> /// <param name="length">how meny days is event</param> /// <returns></returns> public static bool IsInRange(this DateTime value, DateTime date, int length) { length--; HebrewCalendar hd = new HebrewCalendar(); //case 1: The same type of year if (hd.GetDaysInYear(hd.GetYear(value)) == hd.GetDaysInYear(hd.GetYear(date))) { //לא נכון למקרה הזה יכול להיות שימושי במקרים אחרים //if (hd.GetDayOfYear(date) + length > hd.GetDaysInYear(hd.GetYear(date))) // length += hd.GetDaysInYear(hd.GetYear(date)); if (hd.GetDayOfYear(value) >= hd.GetDayOfYear(date) && (hd.GetDayOfYear(value) <= (hd.GetDayOfYear(date) + length))) { return(true); } return(false); } int month = hd.GetMonth(value); // all false options: different months(not Adar in leep year) or an erlier day in the month - same length of month if (month < hd.GetMonth(date) && hd.IsLeapYear(hd.GetYear(date)) == false) { return(false); } //both are ether leap or not, The differencse is by the months if (Math.Abs(hd.GetDaysInYear(hd.GetYear(value)) - hd.GetDaysInYear(hd.GetYear(date))) <= 2) { return(CheckRange(hd.GetYear(date), month, hd.GetDayOfMonth(value), value, date, length)); } else if (hd.IsLeapYear(hd.GetYear(value)) == true) { if (month > 6) { month -= 1; } if (hd.GetMonth(value) != 6) { return(CheckRange(hd.GetYear(date), month, hd.GetDayOfMonth(value), value, date, length)); } else { return(false); } } //date is a leap year else { if (month >= 6) { month += 1; } if (hd.GetMonth(date) == 6 || (hd.GetMonth(date) < 6 && (hd.GetMonth(hd.AddDays(date, length)) >= 6))) { return(false); } return(CheckRange(hd.GetYear(date), month, hd.GetDayOfMonth(value), value, date, length)); } }
/// <summary> /// Sets the date according to the Gregorian Calendar /// </summary> /// <param name="date">The Gregorian date</param> public JewishDate(DateTime date) { GregDate = date; HebrewCalendar hebCal = new HebrewCalendar(); Year = hebCal.GetYear(date); Month = hebCal.GetMonth(date); Day = hebCal.GetDayOfMonth(date); DayOfWeek = hebCal.GetDayOfWeek(GregDate); DayOfYear = hebCal.GetDayOfYear(GregDate); }
/// <summary> /// checks if a given day falls out on a hebrew holiday. /// if it is, holiday will hold the specific holiday /// </summary> /// <param name="Day">the day to check</param> /// <param name="holiday">the returning holiday</param> /// <returns></returns> public bool IsHoliday(DateTime Day, out Holiday?holiday) { holiday = null; int month = cal.IsLeapYear(cal.GetYear(Day)) && cal.GetMonth(Day) > 7 ? cal.GetMonth(Day) - 1 : cal.GetMonth(Day); string Date = string.Format("{0},{1}", month, cal.GetDayOfMonth(Day)); if (!Holidays.Any(T => T.Key == Date)) { return(false); } holiday = Holidays[Date]; return(true); }
public static void Main() { // Create an instance of the calendar. HebrewCalendar myCal = new HebrewCalendar(); Console.WriteLine(myCal.ToString()); // Create an instance of the GregorianCalendar. GregorianCalendar myGre = new GregorianCalendar(); // Display the MinSupportedDateTime and its equivalent in the GregorianCalendar. DateTime myMin = myCal.MinSupportedDateTime; Console.Write("MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal.GetMonth(myMin), myCal.GetDayOfMonth(myMin), myCal.GetYear(myMin)); Console.WriteLine(" (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre.GetMonth(myMin), myGre.GetDayOfMonth(myMin), myGre.GetYear(myMin)); // Display the MaxSupportedDateTime and its equivalent in the GregorianCalendar. DateTime myMax = myCal.MaxSupportedDateTime; Console.Write("MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal.GetMonth(myMax), myCal.GetDayOfMonth(myMax), myCal.GetYear(myMax)); Console.WriteLine(" (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre.GetMonth(myMax), myGre.GetDayOfMonth(myMax), myGre.GetYear(myMax)); }
public static List <QueData> GetHeb(DateTime from, DateTime to) { Calendar HebCal = new HebrewCalendar(); int days = (to - from).Days; List <QueData> lst = new List <QueData>(); for (int i = 0; i <= days; i++) { int curMonth = HebCal.GetMonth(from); if (dicHolidays.ContainsKey(curMonth)) { int curDay = HebCal.GetDayOfMonth(from); string hol = dicHolidays[curMonth]; string currentDay = curDay.ToString(); if (hol.Contains("," + currentDay + ",")) { QueData qData = new QueData(); if (curMonth == 9 && from.DayOfWeek == DayOfWeek.Monday)//יום עצמאות ביום שני { qData = getQue(from.AddDays(1), dicHolidaysDesc[curMonth.ToString() + currentDay]); } else if (curMonth == 9 && from.DayOfWeek == DayOfWeek.Friday)//יום עצמאות ביום שישי { qData = getQue(from.AddDays(-1), dicHolidaysDesc[curMonth.ToString() + currentDay]); } else if (curMonth == 9 && from.DayOfWeek == DayOfWeek.Saturday)//יום עצמאות ביום שבת { qData = getQue(from.AddDays(-2), dicHolidaysDesc[curMonth.ToString() + currentDay]); } else { qData = getQue(from, dicHolidaysDesc[curMonth.ToString() + currentDay]); } lst.Add(qData); } } from = from.AddDays(1); } //int curYear = HebCal.GetYear(Today); //int curDay = HebCal.GetDayOfMonth(Today); //DateTime d = HebCal.ToDateTime(curYear, curMonth, curDay, 0, 0, 0, 0); return(lst); }
private void AddHebDate(RichTextBox month_x_y, DateTime gregDate, bool showYear) { try { string textMonth, textDate; int year = hebCal.GetYear(gregDate); int month = hebCal.GetMonth(gregDate); int day = hebCal.GetDayOfMonth(gregDate); int monthsInYear = hebCal.GetMonthsInYear(year); string[] arrDays = { "א", "ב", "ג", "ד", "ה", "ו", "ז", "ח", "ט", "י", "יא", "יב", "יג", "יד", "טו", "טז", "יז", "יח", "יט", "כ", "כא", "כב", "כג", "כד", "כה", "כו", "כז", "כח", "כט", "ל" }; string[] arrMonths12 = { "תשרי", "חשוון", "כסלו", "טבת", "שבט", "אדר", "ניסן", "אייר", "סיוון", "תמוז", "אב", "אלול" }; string[] arrMonths13 = { "תשרי", "חשוון", "כסלו", "טבת", "שבט", "אדר א", "אדר ב", "ניסן", "אייר", "סיוון", "תמוז", "אב", "אלול" }; if (monthsInYear == 13) { textMonth = arrMonths13[month - 1]; } else { textMonth = arrMonths12[month - 1]; } textDate = arrDays[day - 1] + " " + textMonth; month_x_y.AppendText(Environment.NewLine + textDate); month_x_y.SelectionAlignment = HorizontalAlignment.Right; if (day == 1 || showYear) { month_x_y.AppendText(Environment.NewLine + GetStringHebYear(year)); month_x_y.SelectionAlignment = HorizontalAlignment.Right; //Check for hebYear is in db. if not, let the user know that info might be incorrect. CheckHebYearInDB(year); } } catch (Exception err) { MessageBox.Show("AddHebDate failed\n" + err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void Main() { HebrewCalendar hc = new HebrewCalendar(); DateTime date1 = new DateTime(5771, 6, 1, hc); DateTime date2 = hc.ToDateTime(5771, 6, 1, 0, 0, 0, 0); Console.WriteLine("{0:d} (Gregorian) = {1:d2}/{2:d2}/{3:d4} ({4}): {5}", date1, hc.GetMonth(date2), hc.GetDayOfMonth(date2), hc.GetYear(date2), GetCalendarName(hc), date1.Equals(date2)); }
public HebrewDateResponse(DateTime date) { var hebrewCalendar = new HebrewCalendar(); var year = hebrewCalendar.GetYear(date); var month = hebrewCalendar.GetMonth(date); var day = hebrewCalendar.GetDayOfMonth(date); CultureInfo culture = CultureInfo.CreateSpecificCulture("he-IL"); culture.DateTimeFormat.Calendar = hebrewCalendar; Thread.CurrentThread.CurrentCulture = culture; HebrewDate = $"{year.ToString().PadLeft(4, '0')}-{month.ToString().PadLeft(2, '0')}-{day.ToString().PadLeft(2, '0')}"; WrittenDate = $"{day} {GetHebrewMonthDate(month, year, hebrewCalendar)} {year}"; }
public static bool IsDateInHoliday(DateTime date) { Calendar HebCal = new HebrewCalendar(); int curMonth = HebCal.GetMonth(date); if (dicHolidays.ContainsKey(curMonth)) { string hol = dicHolidays[curMonth]; int curDay = HebCal.GetDayOfMonth(date); string currentDay = curDay.ToString(); if (curMonth == 9)//עצמאות { string azmautDay = HebCal.GetDayOfMonth(date.AddDays(1)).ToString(); if (hol.Contains("," + azmautDay + ",") && date.AddDays(1).DayOfWeek == DayOfWeek.Friday) { return(true); } string azmautDay2 = HebCal.GetDayOfMonth(date.AddDays(2)).ToString(); if (hol.Contains("," + azmautDay2 + ",") && date.AddDays(2).DayOfWeek == DayOfWeek.Saturday) { return(true); } string azmautDay3 = HebCal.GetDayOfMonth(date.AddDays(-1)).ToString(); if (hol.Contains("," + azmautDay3 + ",") && date.AddDays(-1).DayOfWeek == DayOfWeek.Monday) { return(true); } } if (hol.Contains("," + currentDay + ",")) { if (curMonth == 9)//עצמאות { if (date.DayOfWeek == DayOfWeek.Monday || date.DayOfWeek == DayOfWeek.Friday || date.DayOfWeek == DayOfWeek.Saturday) { return(false); } } return(true); } } return(false); }
private string GetHebDateAnnuals(DateTime date) { string hebDateAnnuals = ""; try { HebrewCalendar hebDate = new HebrewCalendar(); int year = hebDate.GetYear(date), month = hebDate.GetMonth(date), day = hebDate.GetDayOfMonth(date); OleDbCommand datacommand = new OleDbCommand(); datacommand.Connection = dataConnection; datacommand.CommandText = "SELECT * " + "FROM tblAnnuals " + "ORDER BY annualID"; OleDbDataReader dataReader = datacommand.ExecuteReader(); while (dataReader.Read()) { string annualID = dataReader.GetInt32(0).ToString(); string annualType = dataReader.GetString(1); string annualName = dataReader.GetString(2); int annualMonth = dataReader.GetInt32(4); int annualDay = dataReader.GetInt32(5); bool annualGreg = dataReader.GetBoolean(6); string annualPicture = dataReader.GetString(7); if (annualGreg) { continue; } if (annualMonth == month && annualDay == day) { hebDateAnnuals += GetEventString(annualID, annualType, annualName, annualPicture); hebDateAnnuals += Environment.NewLine + Environment.NewLine; } } dataReader.Close(); return(hebDateAnnuals); } catch (Exception err) { MessageBox.Show("GetHebDateAnnuals (mouse hover) failed\n" + err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return("Failed"); } }
public static int HeberewMonth(this DateTime value) { HebrewCalendar hd = new HebrewCalendar(); return(hd.GetMonth(value)); }
private void AddHolidays() { try { int index = 0; //first shabbat after simchat torah DateTime currentShabbat = GetDateTimeHebDate(hebYear, 1, 22); while (currentShabbat.DayOfWeek != DayOfWeek.Saturday) { currentShabbat = currentShabbat.AddDays(1); } bool leap = hebCal.IsLeapYear(hebYear); int month, day; //loop till passes next simchat torah while (DateTime.Compare(currentShabbat, GetDateTimeHebDate(hebYear + 1, 1, 22)) <= 0) { month = hebCal.GetMonth(currentShabbat); day = hebCal.GetDayOfMonth(currentShabbat); //rosh hasana if (month == 1 && (day == 1 || day == 2)) { AddInIndex("ראש השנה", index); } //kipur else if (month == 1 && day == 10) { AddInIndex("יום כיפור", index); } //succot else if (month == 1 && (day <= 21 && day >= 15)) { AddInIndex("סוכות", index); } else if (month == 1 && day == 22) { AddInIndex("שמחת תורה", index); } //passover and shavout for leap year else if (leap) { if (month == 8 && day >= 15 && day <= 21) { AddInIndex("פסח", index); } if (month == 10 && day == 6) { AddInIndex("שבועות", index); } } //passover and shavout for nonleap year else if (month == 7 && day >= 15 && day <= 21) { AddInIndex("פסח", index); } else if (month == 9 && day == 6) { AddInIndex("שבועות", index); } currentShabbat = currentShabbat.AddDays(7); index++; } } catch (Exception err) { MessageBox.Show("AddHolidays failed\n" + err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public IEnumerable <ComplexZmanimCalendar> GetDaysInHebrewMonth(DateTime yearAndMonth, GeoLocation location) { Calendar calendar = new HebrewCalendar(); var daysInMonth = calendar.GetDaysInMonth(calendar.GetYear(yearAndMonth), calendar.GetMonth(yearAndMonth)); for (int i = 0; i < daysInMonth; i++) { var zmanimCalendar = new ComplexZmanimCalendar(location); zmanimCalendar.DateWithLocation.Date = new DateTime(yearAndMonth.Year, yearAndMonth.Month, i + 1); yield return(zmanimCalendar); } }
protected void Page_Load(object sender, EventArgs e) { if ((bool)Session["Loged_In"]) { dt = ADO.GetFullTable("Work_Table", " ID=" + Session["ID"] + " And week= 0"); SUM = dt.Rows[0]["sunday_morning"].ToString(); MM = dt.Rows[0]["monday_morning"].ToString(); TUM = dt.Rows[0]["tuesday_morning"].ToString(); WM = dt.Rows[0]["wednesday_morning"].ToString(); THM = dt.Rows[0]["thursday_morning"].ToString(); FM = dt.Rows[0]["friday_morning"].ToString(); SAM = dt.Rows[0]["saturday_morning"].ToString(); SUI = dt.Rows[0]["sunday_intermediate"].ToString(); MI = dt.Rows[0]["monday_intermediate"].ToString(); TUI = dt.Rows[0]["tuesday_intermediate"].ToString(); WI = dt.Rows[0]["wednesday_intermediate"].ToString(); THI = dt.Rows[0]["thursday_intermediate"].ToString(); FI = dt.Rows[0]["friday_intermediate"].ToString(); SAI = dt.Rows[0]["saturday_intermediate"].ToString(); SUE = dt.Rows[0]["sunday_evening"].ToString(); ME = dt.Rows[0]["monday_evening"].ToString(); TUE = dt.Rows[0]["tuesday_evening"].ToString(); WE = dt.Rows[0]["wednesday_evening"].ToString(); THE = dt.Rows[0]["thursday_evening"].ToString(); FE = dt.Rows[0]["friday_evening"].ToString(); SAE = dt.Rows[0]["saturday_evening"].ToString(); DataTable dr = ADO.GetFullTable("Options", "ID=" + (int)Session["ID"]); shifts_ready = !bool.Parse(dt.Rows[0]["Allow_Changes"].ToString()); Allow_Changes = (!shifts_ready) && (Get_Day_Num(DateTime.Now.DayOfWeek.ToString()) < int.Parse(dr.Rows[0]["shift_until"].ToString())); SM = dr.Rows[0]["start_morning_shift"].ToString(); EM = dr.Rows[0]["end_morning_shift"].ToString(); SE = dr.Rows[0]["start_evening_shift"].ToString(); EE = dr.Rows[0]["end_evening_shift"].ToString(); Length_Of_Boxes = (int)dr.Rows[0]["Length_Of_Boxes"]; Length_Of_T_Boxes = (int)dr.Rows[0]["Length_Of_Temp_Boxes"]; if (!bool.Parse(Session["Admin"].ToString())) { worker = ADO.GetFullTable("Workers", "ID=" + Session["ID"] + " AND NameW='" + Session["Wname"] + "'"); use_jobs = bool.Parse(dr.Rows[0]["Use_Jobs"].ToString()); if (use_jobs) { short_job = worker.Rows[0]["Job"].ToString(); } } intermediate_Shifts = bool.Parse(dr.Rows[0]["intermediate_Shifts"].ToString()); Width_Of_Boxes = 13; trance_name = Trans_To_english(Session["wname"].ToString()); if ((!shifts_ready) && (!bool.Parse(Session["Admin"].ToString())) && (!first_log_in_week)) {//shifts not ready and the person isnt admin string name = ""; if (use_jobs) { name = short_job + "|" + Session["wname"].ToString(); } else { name = Session["wname"].ToString(); } if (SUM.Contains(name)) { SUM = SUM.Substring(SUM.IndexOf(name), Width_Of_Boxes); } else { SUM = ""; } if (MM.Contains(name)) { MM = MM.Substring(MM.IndexOf(name), Width_Of_Boxes); } else { MM = ""; } if (TUM.Contains(name)) { TUM = TUM.Substring(TUM.IndexOf(name), Width_Of_Boxes); } else { TUM = ""; } if (WM.Contains(name)) { WM = WM.Substring(WM.IndexOf(name), Width_Of_Boxes); } else { WM = ""; } if (THM.Contains(name)) { THM = THM.Substring(THM.IndexOf(name), Width_Of_Boxes); } else { THM = ""; } if (FM.Contains(name)) { FM = FM.Substring(FM.IndexOf(name), Width_Of_Boxes); } else { FM = ""; } if (SAM.Contains(name)) { SAM = SAM.Substring(SAM.IndexOf(name), Width_Of_Boxes); } else { SAM = ""; } #region intermediat... string temp = SUI; SUI = ""; while (temp.Contains(name)) { SUI += temp.Substring(temp.IndexOf(name), Width_Of_Boxes * 2); temp = temp.Remove(temp.IndexOf(name), Width_Of_Boxes * 2); } temp = MI; MI = ""; while (temp.Contains(name)) { MI += temp.Substring(temp.IndexOf(name), Width_Of_Boxes * 2); temp = temp.Remove(temp.IndexOf(name), Width_Of_Boxes * 2); } temp = TUI; TUI = ""; while (temp.Contains(name)) { TUI += temp.Substring(temp.IndexOf(name), Width_Of_Boxes * 2); temp = temp.Remove(temp.IndexOf(name), Width_Of_Boxes * 2); } temp = WI; WI = ""; while (temp.Contains(name)) { WI += temp.Substring(temp.IndexOf(name), Width_Of_Boxes * 2); temp = temp.Remove(temp.IndexOf(name), Width_Of_Boxes * 2); } temp = THI; THI = ""; while (temp.Contains(name)) { THI += temp.Substring(temp.IndexOf(name), Width_Of_Boxes * 2); temp = temp.Remove(temp.IndexOf(name), Width_Of_Boxes * 2); } temp = FI; FI = ""; while (temp.Contains(name)) { FI += temp.Substring(temp.IndexOf(name), Width_Of_Boxes * 2); temp = temp.Remove(temp.IndexOf(name), Width_Of_Boxes * 2); } temp = SAI; SAI = ""; while (temp.Contains(name)) { SAI += temp.Substring(temp.IndexOf(name), Width_Of_Boxes * 2); temp = temp.Remove(temp.IndexOf(name), Width_Of_Boxes * 2); } #endregion if (SUE.Contains(name)) { SUE = SUE.Substring(SUE.IndexOf(name), Width_Of_Boxes); } else { SUE = ""; } if (ME.Contains(name)) { ME = ME.Substring(ME.IndexOf(name), Width_Of_Boxes); } else { ME = ""; } if (TUE.Contains(name)) { TUE = TUE.Substring(TUE.IndexOf(name), Width_Of_Boxes); } else { TUE = ""; } if (WE.Contains(name)) { WE = WE.Substring(WE.IndexOf(name), Width_Of_Boxes); } else { WE = ""; } if (THE.Contains(name)) { THE = THE.Substring(THE.IndexOf(name), Width_Of_Boxes); } else { THE = ""; } if (FE.Contains(name)) { FE = FE.Substring(FE.IndexOf(name), Width_Of_Boxes); } else { FE = ""; } if (SAE.Contains(name)) { SAE = SAE.Substring(SAE.IndexOf(name), Width_Of_Boxes); } else { SAE = ""; } } un = ADO.GetFullTable("Users", "ID=" + (int)Session["ID"]).Rows[0]["UserName"].ToString(); events = new string[7]; HebrewCalendar heb = new HebrewCalendar(); DateTime date = DateTime.Now; while (date.DayOfWeek.ToString() != "Sunday") { date = date.AddDays(-1); } DataTable holydays; if (heb.IsLeapYear(heb.GetYear(date))) { holydays = ADO.GetFullTable("Holiday", "day=" + heb.GetDayOfMonth(date) + " AND leap_month=" + heb.GetMonth(date) + " OR day=" + heb.GetDayOfMonth(date.AddDays(1)) + " AND leap_month=" + heb.GetMonth(date.AddDays(1)) + " OR day=" + heb.GetDayOfMonth(date.AddDays(2)) + " AND leap_month=" + heb.GetMonth(date.AddDays(2)) + " OR day=" + heb.GetDayOfMonth(date.AddDays(3)) + " AND leap_month=" + heb.GetMonth(date.AddDays(3)) + " OR day=" + heb.GetDayOfMonth(date.AddDays(4)) + " AND leap_month=" + heb.GetMonth(date.AddDays(4)) + " OR day=" + heb.GetDayOfMonth(date.AddDays(5)) + " AND leap_month=" + heb.GetMonth(date.AddDays(5)) + " OR day=" + heb.GetDayOfMonth(date.AddDays(6)) + " AND leap_month=" + heb.GetMonth(date.AddDays(6)) + ""); } else { holydays = ADO.GetFullTable("Holiday", "day=" + heb.GetDayOfMonth(date) + " AND month=" + heb.GetMonth(date) + " OR day=" + heb.GetDayOfMonth(date.AddDays(1)) + " AND month=" + heb.GetMonth(date.AddDays(1)) + " OR day=" + heb.GetDayOfMonth(date.AddDays(2)) + " AND month=" + heb.GetMonth(date.AddDays(2)) + " OR day=" + heb.GetDayOfMonth(date.AddDays(3)) + " AND month=" + heb.GetMonth(date.AddDays(3)) + " OR day=" + heb.GetDayOfMonth(date.AddDays(4)) + " AND month=" + heb.GetMonth(date.AddDays(4)) + " OR day=" + heb.GetDayOfMonth(date.AddDays(5)) + " AND month=" + heb.GetMonth(date.AddDays(5)) + " OR day=" + heb.GetDayOfMonth(date.AddDays(6)) + " AND month=" + heb.GetMonth(date.AddDays(6)) + ""); } foreach (DataRow holyday in holydays.Rows) { for (int i = 0; i < 7; i++) { if (heb.GetDayOfMonth(date.AddDays(i)) == int.Parse(holyday["day"].ToString())) { if (holyday["Link"].ToString() != "") { events[i] = "<a href='" + holyday["Link"].ToString() + "' target='_blank'>" + holyday["name_of_holiday"].ToString() + "</a>"; } else { events[i] = holyday["name_of_holiday"].ToString(); } } } } } else { Session.Abandon(); Response.Redirect("Default.aspx"); } }