/// <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))); }
[Test, Timeout(300000)] // Can take a long time under NCrunch. public void BclThroughHistory_Scriptural() { Calendar bcl = new HebrewCalendar(); var noda = CalendarSystem.HebrewScriptural; // The min supported date/time starts part way through the year var minYear = bcl.GetYear(bcl.MinSupportedDateTime) + 1; // The max supported date/time ends part way through the year var maxYear = bcl.GetYear(bcl.MaxSupportedDateTime) - 1; // Can't use BclEquivalenceHelper for this one, because of the month conversions. for (int year = minYear; year <= maxYear; year++) { int months = bcl.GetMonthsInYear(year); Assert.AreEqual(months, noda.GetMonthsInYear(year)); for (int civilMonth = 1; civilMonth <= months; civilMonth++) { int scripturalMonth = HebrewMonthConverter.CivilToScriptural(year, civilMonth); Assert.AreEqual(bcl.GetDaysInMonth(year, civilMonth), noda.GetDaysInMonth(year, scripturalMonth), "Year: {0}; Month: {1} (civil)", year, civilMonth); for (int day = 1; day < bcl.GetDaysInMonth(year, civilMonth); day++) { DateTime bclDate = new DateTime(year, civilMonth, day, bcl); LocalDate nodaDate = new LocalDate(year, scripturalMonth, day, noda); Assert.AreEqual(bclDate, nodaDate.AtMidnight().ToDateTimeUnspecified(), "{0}-{1}-{2}", year, scripturalMonth, day); Assert.AreEqual(nodaDate, LocalDateTime.FromDateTime(bclDate, noda).Date); Assert.AreEqual(year, nodaDate.Year); Assert.AreEqual(scripturalMonth, nodaDate.Month); Assert.AreEqual(day, nodaDate.Day); } } } }
[Test, Timeout(300000)] // Can take a long time under NCrunch. public void BclThroughHistory_Civil() { Calendar bcl = new HebrewCalendar(); var noda = CalendarSystem.GetHebrewCalendar(HebrewMonthNumbering.Civil); // The min supported date/time starts part way through the year var minYear = bcl.GetYear(bcl.MinSupportedDateTime) + 1; // The max supported date/time ends part way through the year var maxYear = bcl.GetYear(bcl.MaxSupportedDateTime) - 1; for (int year = minYear; year <= maxYear; year++) { int months = bcl.GetMonthsInYear(year); Assert.AreEqual(months, noda.GetMaxMonth(year)); for (int month = 1; month <= months; month++) { Assert.AreEqual(bcl.GetDaysInMonth(year, month), noda.GetDaysInMonth(year, month), "Year: {0}; Month: {1}", year, month); for (int day = 1; day < bcl.GetDaysInMonth(year, month); day++) { DateTime bclDate = new DateTime(year, month, day, bcl); LocalDate nodaDate = new LocalDate(year, month, day, noda); Assert.AreEqual(bclDate, nodaDate.AtMidnight().ToDateTimeUnspecified()); Assert.AreEqual(nodaDate, LocalDateTime.FromDateTime(bclDate).WithCalendar(noda).Date); Assert.AreEqual(year, nodaDate.Year); Assert.AreEqual(month, nodaDate.Month); Assert.AreEqual(day, nodaDate.Day); } } } }
/// <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)); } }
public void DaysInYear() { var bcl = new HebrewCalendar(); var minYear = bcl.GetYear(bcl.MinSupportedDateTime); var maxYear = bcl.GetYear(bcl.MaxSupportedDateTime); for (int year = minYear; year <= maxYear; year++) { Assert.AreEqual(bcl.GetDaysInYear(year), HebrewScripturalCalculator.DaysInYear(year)); } }
public void IsLeapYear() { var bcl = new HebrewCalendar(); var minYear = bcl.GetYear(bcl.MinSupportedDateTime); var maxYear = bcl.GetYear(bcl.MaxSupportedDateTime); var noda = CalendarSystem.HebrewCivil; for (int year = minYear; year <= maxYear; year++) { Assert.AreEqual(bcl.IsLeapYear(year), noda.IsLeapYear(year)); } }
[Test, Timeout(300000)] // Can take a long time under NCrunch. public void BclThroughHistory_Civil() { Calendar bcl = new HebrewCalendar(); var noda = CalendarSystem.HebrewCivil; // The min supported date/time starts part way through the year var minYear = bcl.GetYear(bcl.MinSupportedDateTime) + 1; // The max supported date/time ends part way through the year var maxYear = bcl.GetYear(bcl.MaxSupportedDateTime) - 1; BclEquivalenceHelper.AssertEquivalent(bcl, noda, minYear, maxYear); }
public static string GetHebrewDate(DateTime gregorianDate) { Calendar HebCal = new HebrewCalendar(); string hebrewDate = $"{HebCal.GetYear(gregorianDate)}-{HebCal.GetMonth(gregorianDate)}-{HebCal.GetDayOfMonth(gregorianDate)}"; return(hebrewDate); }
///<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); }
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> /// متد تبديل تاريخ ميلادي به هبري /// </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); }
[Test] // wrt bug #76252. public void HebrewCalendarGetDaysInMonth() { HebrewCalendar c = new HebrewCalendar(); int year = c.GetYear(new DateTime(2005, 9, 1)); Assert.AreEqual(5765, year); int days = c.GetDaysInMonth(year, 13, 1); Assert.AreEqual(29, days); }
public void DaysInMonth() { var bcl = new HebrewCalendar(); // Not all months in the min/max years are supported var minYear = bcl.GetYear(bcl.MinSupportedDateTime) + 1; var maxYear = bcl.GetYear(bcl.MaxSupportedDateTime) - 1; for (int year = minYear; year <= maxYear; year++) { int months = bcl.GetMonthsInYear(year); for (int month = 1; month <= months; month++) { int scripturalMonth = HebrewMonthConverter.CivilToScriptural(year, month); int bclDays = bcl.GetDaysInMonth(year, month); int nodaDays = HebrewScripturalCalculator.DaysInMonth(year, scripturalMonth); Assert.AreEqual(bclDays, nodaDays); } } }
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); } }
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> /// 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); }
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 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(); }
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 IEnumerable <ComplexZmanimCalendar> GetDaysInHebrewYear(DateTime year, GeoLocation location) { Calendar calendar = new HebrewCalendar(); var currentYear = calendar.GetYear(year); var amountOfMonths = calendar.GetMonthsInYear(currentYear); for (int i = 0; i < amountOfMonths; i++) { var currentMonth = i + 1; var daysInMonth = calendar.GetDaysInMonth(currentYear, currentMonth); for (int dayOfMonth = 0; dayOfMonth < daysInMonth; dayOfMonth++) { var zmanimCalendar = new ComplexZmanimCalendar(location); zmanimCalendar.DateWithLocation.Date = new DateTime(currentYear, currentMonth, dayOfMonth + 1, calendar); 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"); } }
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)); }