private void fillArrays() { try { var ci = new CultureInfo(PNLang.Instance.GetLanguageCulture()); var first = CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek; _DayNamesAbbr = ci.DateTimeFormat.AbbreviatedDayNames; _DayNamesFull = ci.DateTimeFormat.DayNames; _DaysOfWeek = Enum.GetValues(typeof(DayOfWeek)).OfType <DayOfWeek>().ToArray(); var diff = (int)first - (int)DayOfWeek.Sunday; if (diff > 0) { var tDayW = new DayOfWeek[diff]; Array.Copy(_DaysOfWeek, 0, tDayW, 0, diff); var tAbbr = new string[diff]; Array.Copy(_DayNamesAbbr, 0, tAbbr, 0, diff); var tFull = new string[diff]; Array.Copy(_DayNamesFull, 0, tFull, 0, diff); for (int i = 0, j = diff; j < _DayNamesFull.Length; i++, j++) { _DaysOfWeek[i] = _DaysOfWeek[j]; _DayNamesAbbr[i] = _DayNamesAbbr[j]; _DayNamesFull[i] = _DayNamesFull[j]; } Array.Copy(tDayW, 0, _DaysOfWeek, _DaysOfWeek.Length - diff, diff); Array.Copy(tAbbr, 0, _DayNamesAbbr, _DayNamesAbbr.Length - diff, diff); Array.Copy(tFull, 0, _DayNamesFull, _DayNamesFull.Length - diff, diff); for (var i = 0; i < _DayNamesFull.Length; i++) { _DwRealFull[i] = new DwReal { Name = _DayNamesFull[i], DayW = _DaysOfWeek[i] }; _DwRealAbbr[i] = new DwReal { Name = _DayNamesAbbr[i], DayW = _DaysOfWeek[i] }; } } else { for (var i = 0; i < _DayNamesFull.Length; i++) { _DwRealFull[i] = new DwReal { Name = _DayNamesFull[i], DayW = _DaysOfWeek[i] }; _DwRealAbbr[i] = new DwReal { Name = _DayNamesAbbr[i], DayW = _DaysOfWeek[i] }; } } } catch (Exception ex) { PNStatic.LogException(ex); } }
private void fillArrays() { try { var ci = new CultureInfo(PNLang.Instance.GetLanguageCulture()); var first = CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek; _DayNamesAbbr = ci.DateTimeFormat.AbbreviatedDayNames; _DayNamesFull = ci.DateTimeFormat.DayNames; _DaysOfWeek = Enum.GetValues(typeof(DayOfWeek)).OfType<DayOfWeek>().ToArray(); var diff = (int)first - (int)DayOfWeek.Sunday; if (diff > 0) { var tDayW = new DayOfWeek[diff]; Array.Copy(_DaysOfWeek, 0, tDayW, 0, diff); var tAbbr = new string[diff]; Array.Copy(_DayNamesAbbr, 0, tAbbr, 0, diff); var tFull = new string[diff]; Array.Copy(_DayNamesFull, 0, tFull, 0, diff); for (int i = 0, j = diff; j < _DayNamesFull.Length; i++, j++) { _DaysOfWeek[i] = _DaysOfWeek[j]; _DayNamesAbbr[i] = _DayNamesAbbr[j]; _DayNamesFull[i] = _DayNamesFull[j]; } Array.Copy(tDayW, 0, _DaysOfWeek, _DaysOfWeek.Length - diff, diff); Array.Copy(tAbbr, 0, _DayNamesAbbr, _DayNamesAbbr.Length - diff, diff); Array.Copy(tFull, 0, _DayNamesFull, _DayNamesFull.Length - diff, diff); for (var i = 0; i < _DayNamesFull.Length; i++) { _DwRealFull[i] = new DwReal { Name = _DayNamesFull[i], DayW = _DaysOfWeek[i] }; _DwRealAbbr[i] = new DwReal { Name = _DayNamesAbbr[i], DayW = _DaysOfWeek[i] }; } } else { for (var i = 0; i < _DayNamesFull.Length; i++) { _DwRealFull[i] = new DwReal { Name = _DayNamesFull[i], DayW = _DaysOfWeek[i] }; _DwRealAbbr[i] = new DwReal { Name = _DayNamesAbbr[i], DayW = _DaysOfWeek[i] }; } } } catch (Exception ex) { PNStatic.LogException(ex); } }