private string[] SemanaSalidas(int week, int year, int[] dias) { int entra = dias[0], descabece = dias[1], saleKFC = dias[2], salePie = dias[3]; Calendar c = new CultureInfo("en-US").Calendar; CalendarWeekRule cwr = CalendarWeekRule.FirstDay; DayOfWeek dw = DayOfWeek.Monday; DateTime enterDate = new DateTime(year, 1, 1); int daysOffset = DayOfWeek.Monday - enterDate.DayOfWeek; enterDate = c.AddDays(enterDate, daysOffset); if (enterDate.Year != year) { enterDate = c.AddWeeks(enterDate, 1); } int num = c.GetWeekOfYear(enterDate, cwr, dw); num = week - num; enterDate = c.AddWeeks(enterDate, num); enterDate = c.AddDays(enterDate, entra - 1); string partial = "-" + year.ToString(); return(new string[] { c.GetWeekOfYear(c.AddDays(enterDate, descabece), cwr, dw).ToString().PadLeft(2, '0') + partial, c.GetWeekOfYear(c.AddDays(enterDate, saleKFC), cwr, dw).ToString().PadLeft(2, '0') + partial, c.GetWeekOfYear(c.AddDays(enterDate, salePie), cwr, dw).ToString().PadLeft(2, '0') + partial }); }
static MonthCalendarProvider() { // XXX: Mono's MonthCalendar control seems to only // support the Gregorian calendar. // Calendar cal = Thread.CurrentThread.CurrentCulture.Calendar; Calendar cal = new CultureInfo("en-US").Calendar; numDaysInWeek = (cal.AddWeeks(fixedDate, 1) - fixedDate).Days; }