Example #1
0
        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 });
        }
Example #2
0
 /// <summary>
 /// Inherited code: Requires comment.
 /// </summary>
 /// <param name="time">Inherited code: Requires comment 1.</param>
 /// <param name="days">Inherited code: Requires comment 2.</param>
 /// <returns>Inherited code: Requires comment 3.</returns>
 public static DateTime?AddDays(DateTime time, int days)
 {
     System.Globalization.Calendar cal = new CultureInfo("en-US").Calendar;
     try
     {
         return(cal.AddDays(time, days));
     }
     catch (ArgumentException)
     {
         return(null);
     }
 }