public static void Main() { string[] myDateTimePatterns = new string[] { "MM/dd/yy", "MM/dd/yyyy" }; // Get the en-US culture. CultureInfo ci = new CultureInfo("en-US"); // Get the DateTimeFormatInfo for the en-US culture. DateTimeFormatInfo dtfi = ci.DateTimeFormat; // Display the effective culture. Console.WriteLine("This code example uses the {0} culture.", ci.Name); // Display the native calendar name. Console.WriteLine("\nNativeCalendarName..."); Console.WriteLine("\"{0}\"", dtfi.NativeCalendarName); // Display month genitive names. Console.WriteLine("\nMonthGenitiveNames..."); foreach (string name in dtfi.MonthGenitiveNames) { Console.WriteLine("\"{0}\"", name); } // Display abbreviated month genitive names. Console.WriteLine("\nAbbreviatedMonthGenitiveNames..."); foreach (string name in dtfi.AbbreviatedMonthGenitiveNames) { Console.WriteLine("\"{0}\"", name); } // Display shortest day names. Console.WriteLine("\nShortestDayNames..."); foreach (string name in dtfi.ShortestDayNames) { Console.WriteLine("\"{0}\"", name); } // Display shortest day name for a particular day of the week. Console.WriteLine("\nGetShortestDayName(DayOfWeek.Sunday)..."); Console.WriteLine("\"{0}\"", dtfi.GetShortestDayName(DayOfWeek.Sunday)); // Display the initial DateTime format patterns for the 'd' format specifier. Console.WriteLine("\nInitial DateTime format patterns for the 'd' format specifier..."); foreach (string name in dtfi.GetAllDateTimePatterns('d')) { Console.WriteLine("\"{0}\"", name); } // Change the initial DateTime format patterns for the 'd' DateTime format specifier. Console.WriteLine("\nChange the initial DateTime format patterns for the \n" + "'d' format specifier to my format patterns..."); dtfi.SetAllDateTimePatterns(myDateTimePatterns, 'd'); // Display the new DateTime format patterns for the 'd' format specifier. Console.WriteLine("\nNew DateTime format patterns for the 'd' format specifier..."); foreach (string name in dtfi.GetAllDateTimePatterns('d')) { Console.WriteLine("\"{0}\"", name); } }
public static string getRRule(long p_scheduleType, string p_StartTime, string p_dayoftheweek) { string interval; DateTime dt; switch (p_scheduleType) { case 1: dt = new DateTime(2021, 01, 01); interval = "2"; break; case 2: dt = new DateTime(2021, 01, 01).AddDays(7); interval = "2"; break; default: dt = new DateTime(2021, 01, 01); interval = "1"; break; } string rrule = "DTSTART:" + dt.ToString("yyyyMMdd") + "T" + p_StartTime.Replace(":", "") + "00"; rrule += "\nRRULE:FREQ=WEEKLY;INTERVAL=" + interval + ";"; CultureInfo ci = new CultureInfo("en-US"); DateTimeFormatInfo dtfi = ci.DateTimeFormat; rrule += "BYDAY=" + dtfi.GetShortestDayName((DayOfWeek)int.Parse(p_dayoftheweek)).ToUpper(); return(rrule); }
public static string GetShortestDayName(this DateTime dateTime) { string cultureinfo = ConfigurationManager.AppSettings["DefaultCulture"]; CultureInfo ci = new CultureInfo(cultureinfo); DateTimeFormatInfo dateTimeInfo = ci.DateTimeFormat; return(dateTimeInfo.GetShortestDayName(dateTime.DayOfWeek)); }
private TableRow CreateDayHeader(DateTime firstDay, DateTime visibleDate, System.Globalization.Calendar threadCalendar) { TableRow row = new TableRow(); DateTimeFormatInfo dtf = DateTimeFormatInfo.CurrentInfo; TableItemStyle dayNameStyle = new TableItemStyle(); dayNameStyle.HorizontalAlign = HorizontalAlign.Center; dayNameStyle.CopyFrom(DayHeaderStyle); DayNameFormat dayNameFormat = DayNameFormat; int numericFirstDay = (int)threadCalendar.GetDayOfWeek(firstDay); for (int i = numericFirstDay; i < numericFirstDay + 7; i++) { string dayName; int dayOfWeek = i % 7; switch (dayNameFormat) { case DayNameFormat.FirstLetter: dayName = dtf.GetDayName((DayOfWeek)dayOfWeek).Substring(0, 1); break; case DayNameFormat.FirstTwoLetters: dayName = dtf.GetDayName((DayOfWeek)dayOfWeek).Substring(0, 2); break; case DayNameFormat.Full: dayName = dtf.GetDayName((DayOfWeek)dayOfWeek); break; case DayNameFormat.Short: dayName = dtf.GetAbbreviatedDayName((DayOfWeek)dayOfWeek); break; case DayNameFormat.Shortest: dayName = dtf.GetShortestDayName((DayOfWeek)dayOfWeek); break; default: System.Diagnostics.Debug.Assert(false, "Unknown DayNameFormat value!"); goto case DayNameFormat.Short; } TableCell cell = new TableCell(); cell.ApplyStyle(dayNameStyle); cell.Text = dayName; row.Cells.Add(cell); } return(row); }
private void ShowDayNames(Label Mo, Label Tu, Label We, Label Th, Label Fr, Label Sa, Label Su) { CultureInfo ci = CultureInfo.CurrentCulture; DateTimeFormatInfo dtfi = ci.DateTimeFormat; Mo.Content = dtfi.GetShortestDayName(DayOfWeek.Monday); Tu.Content = dtfi.GetShortestDayName(DayOfWeek.Tuesday); We.Content = dtfi.GetShortestDayName(DayOfWeek.Wednesday); Th.Content = dtfi.GetShortestDayName(DayOfWeek.Thursday); Fr.Content = dtfi.GetShortestDayName(DayOfWeek.Friday); Sa.Content = dtfi.GetShortestDayName(DayOfWeek.Saturday); Su.Content = dtfi.GetShortestDayName(DayOfWeek.Sunday); }
public static List <Cell> getDaysOfWeekRow(DateTime from, DateTime to) { List <Cell> daysOfWeekRow = new List <Cell>(); DateTimeFormatInfo dfi = new DateTimeFormatInfo() { FirstDayOfWeek = DayOfWeek.Monday, CalendarWeekRule = CalendarWeekRule.FirstDay }; for (DateTime date = from; date <= to; date = date.AddDays(1)) { daysOfWeekRow.Add(new Cell(font, dfi.GetShortestDayName(date.DayOfWeek))); } return(daysOfWeekRow); }
protected virtual void OnRenderDayHeader(HtmlTextWriter writer, DateTime visibleDate, CalendarSelectionMode selectionMode, bool buttonsActive) { writer.Write("<tr>"); DateTimeFormatInfo currentInfo = GetDateTimeFormatter(); if (this.HasWeekSelectors(selectionMode)) { TableItemStyle style = new TableItemStyle(); style.HorizontalAlign = HorizontalAlign.Center; if (selectionMode == CalendarSelectionMode.DayWeekMonth) { int days = visibleDate.Subtract(baseDate).Days; int dayOfMonth = this.threadCalendar.GetDaysInMonth(this.threadCalendar.GetYear(visibleDate), this.threadCalendar.GetMonth(visibleDate), this.threadCalendar.GetEra(visibleDate)); if (this.IsMinSupportedYearMonth(visibleDate)) { dayOfMonth = (dayOfMonth - this.threadCalendar.GetDayOfMonth(visibleDate)) + 1; } else if (this.IsMaxSupportedYearMonth(visibleDate)) { dayOfMonth = this.threadCalendar.GetDayOfMonth(this.maxSupportedDate); } string eventArgument = "R" + (((days * 100) + dayOfMonth)).ToString(CultureInfo.InvariantCulture); style.CopyFrom(this.SelectorStyle); string title = null; this.OnRenderCalendarCell(writer, style, this.SelectMonthText, title, buttonsActive, eventArgument); } else { style.CopyFrom(this.DayHeaderStyle); this.OnRenderCalendarCell(writer, style, string.Empty, null, false, null); } } TableItemStyle weekdayStyle = new TableItemStyle(); weekdayStyle.HorizontalAlign = HorizontalAlign.Center; weekdayStyle.CopyFrom(this.DayHeaderStyle); DayNameFormat dayNameFormat = this.DayNameFormat; int firstDay = this.NumericFirstDayOfWeek(); for (int i = firstDay; i < (firstDay + 7); i++) { string dayName; int dayOfWeekNumber = i % 7; switch (dayNameFormat) { case DayNameFormat.Full: dayName = currentInfo.GetDayName((DayOfWeek)dayOfWeekNumber); break; case DayNameFormat.FirstLetter: dayName = currentInfo.GetDayName((DayOfWeek)dayOfWeekNumber).Substring(0, 1); break; case DayNameFormat.FirstTwoLetters: dayName = currentInfo.GetDayName((DayOfWeek)dayOfWeekNumber).Substring(0, 2); break; case DayNameFormat.Shortest: dayName = currentInfo.GetShortestDayName((DayOfWeek)dayOfWeekNumber); break; default: dayName = currentInfo.GetAbbreviatedDayName((DayOfWeek)dayOfWeekNumber); break; } this.OnRenderCalendarCell(writer, weekdayStyle, dayName, null, false, null); } writer.Write("</tr>"); }
public static string GetShortestDayName(DayOfWeek dayOfWeek) { return(_info.GetShortestDayName(dayOfWeek)); }
// // Private methods // void WriteDayHeader(HtmlTextWriter writer, bool enabled) { int i, first; string dayName; i = first = (int)(DisplayFirstDayOfWeek); TableCell cell; writer.RenderBeginTag(HtmlTextWriterTag.Tr); if (SelectionMode == CalendarSelectionMode.DayWeek) { cell = new TableCell(); cell.HorizontalAlign = HorizontalAlign.Center; cell.ApplyStyle(DayHeaderStyle); // Empty Cell cell.RenderBeginTag(writer); cell.RenderEndTag(writer); } else { if (SelectionMode == CalendarSelectionMode.DayWeekMonth) { TableCell selector = new TableCell(); selector.ApplyStyle(SelectorStyle); selector.HorizontalAlign = HorizontalAlign.Center; DateTime date = new DateTime(DisplayDate.Year, DisplayDate.Month, 1); // first date int days = DateTime.DaysInMonth(DisplayDate.Year, DisplayDate.Month); selector.RenderBeginTag(writer); writer.Write(BuildLink("R" + GetDaysFromZenith(date) + days, SelectMonthText, DayHeaderStyle.ForeColor, enabled)); selector.RenderEndTag(writer); } } DateTimeFormatInfo dti = DateInfo; while (true) { DayOfWeek dayOfWeek = (DayOfWeek)i; dayName = dti.GetDayName(dayOfWeek); if (UseAccessibleHeader) { writer.AddAttribute(HtmlTextWriterAttribute.Abbr, dayName); writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col", false); cell = new TableHeaderCell(); } else { cell = new TableCell(); } cell.HorizontalAlign = HorizontalAlign.Center; cell.ApplyStyle(DayHeaderStyle); cell.RenderBeginTag(writer); switch (DayNameFormat) { case DayNameFormat.FirstLetter: dayName = dayName.Substring(0, 1); break; case DayNameFormat.FirstTwoLetters: dayName = dayName.Substring(0, 2); break; case DayNameFormat.Shortest: dayName = dti.GetShortestDayName(dayOfWeek); break; case DayNameFormat.Full: break; case DayNameFormat.Short: default: dayName = dti.GetAbbreviatedDayName(dayOfWeek); break; } writer.Write(dayName); cell.RenderEndTag(writer); if (i >= daysInAWeek - 1) { i = 0; } else { i++; } if (i == first) { break; } } writer.RenderEndTag(); }
public async Task GetSchulaufgaben() { mvm.SchulaufgabenUndSonstige.Clear(); List <Termine> ret = new List <Termine>(); string datesave = string.Empty; string dat = string.Empty; int counter = 0; var values = new Dictionary <string, string> { }; FormUrlEncodedContent content = new FormUrlEncodedContent(values); var response = await client.PostAsync("https://digikabu.de/SchulaufgabenPlan", content); var responseString = await response.Content.ReadAsStringAsync(); List <string> termine = new List <string>(); string[] split = responseString.Split('>'); string jahr = ""; bool nextisyear = false; foreach (string s in split) { if (nextisyear == true) { Console.WriteLine(s); jahr = s.Split(' ')[1].Replace("</h4", ""); nextisyear = false; } if (s.Contains("<h4")) { nextisyear = true; } switch (counter) { case 6: dat = s.Replace("</strong", "") + jahr; if (CultureInfo.CurrentCulture.Name.Contains("en")) { var splitdat = dat.Split('.'); datesave = $"{splitdat[1]}.{splitdat[0]}.{splitdat[2]}"; } else if (CultureInfo.CurrentCulture.Name == "de-DE") { datesave = dat; } else { datesave = DateTime.Now.ToString(); } break; case 1: if (s != "</td") { termine.Add(datesave + "~" + Fix(s.Replace("</td", ""))); } break; default: break; } counter--; if (s.Contains("tr class=\"\"")) { counter = 8; } } foreach (string s in termine) { var splitTer = s.Split('~'); CultureInfo ci = new CultureInfo("de-DE"); // Get the DateTimeFormatInfo for the en-US culture. DateTimeFormatInfo dtfi = ci.DateTimeFormat; DayOfWeek dow = Convert.ToDateTime(splitTer[0]).DayOfWeek; ret.Add(new Klassen.Termine(dtfi.GetShortestDayName(dow), splitTer[0], splitTer[1])); } mvm.SchulaufgabenUndSonstige = ret; }
public async Task <List <Termine> > GetTermine() { List <Termine> ret = new List <Termine>(); var response = await client.GetAsync("https://digikabu.de/Main"); var responseString = await response.Content.ReadAsStringAsync(); string[] info = new string[2]; bool nextIsIgnore = false, nextIsMessage = false; foreach (string s in responseString.Split('<')) { if (s.Contains("td")) { var trim = s.Trim(); if (trim.Contains("white-space")) { var x = trim.Split('>'); info[0] = Fix(x[1]); nextIsIgnore = true; } else if (nextIsIgnore) { nextIsMessage = true; nextIsIgnore = false; } else if (nextIsMessage) { var x = trim.Split('>'); nextIsMessage = false; info[1] = Fix(x[1]); var dat = string.Empty; if (info[0].Contains(' ')) { dat = info[0].Split(' ')[0]; } else { dat = info[0]; } var retdat = string.Empty; if (CultureInfo.CurrentCulture.Name.Contains("en")) { var splitdat = dat.Split('.'); retdat = $"{splitdat[1]}.{splitdat[0]}.{splitdat[2]}"; } else if (CultureInfo.CurrentCulture.Name == "de-DE") { retdat = dat; } else { retdat = DateTime.Now.ToString(); } CultureInfo ci = new CultureInfo("de-DE"); // Get the DateTimeFormatInfo for the en-US culture. DateTimeFormatInfo dtfi = ci.DateTimeFormat; DayOfWeek dow = Convert.ToDateTime(retdat).DayOfWeek; ret.Add(new Klassen.Termine(dtfi.GetShortestDayName(dow), info[0], info[1])); } } } return(ret); }