public static void Main(string[] args) { Console.WriteLine("__________________________________________________________________________"); Console.WriteLine("---------------- Console Application - Next business day ----------------"); Console.WriteLine("__________________________________________________________________________"); string myChoice; do { Console.WriteLine(); Console.WriteLine("Enter a date and location - Ex: EUA = MM/DD/YYYY en | BRAZIL = DD/MM/YYYY pt "); Console.Write(">>> "); string[] valores = Console.ReadLine().Split(' '); String dt = valores[0]; var cultureInfo = new CultureInfo(valores[1]); DateTime date = DateTime.Parse(dt, cultureInfo); Console.WriteLine(); NextDay.GetAddDays(date); Console.WriteLine("____________________________________________"); Console.Write("Press any key to continue | <N> To Exit >>> "); myChoice = Console.ReadLine(); Console.Clear(); } while (myChoice != "N" && myChoice != "n"); }
public static DateTime GetAddDays(DateTime dateTime) { var publicHolidays = DateSystem.GetPublicHoliday(dateTime, dateTime, CountryCode.BR); if (publicHolidays.Count() > 0) { Console.WriteLine(); if (dateTime.DayOfWeek == DayOfWeek.Saturday) { dateTime = dateTime.AddDays(2); } else if (dateTime.DayOfWeek == DayOfWeek.Sunday) { dateTime = dateTime.AddDays(1); } else { dateTime = dateTime.AddDays(1); } Console.Write("Holiday - Next working day: "); } else if (dateTime.DayOfWeek == DayOfWeek.Saturday) { dateTime = dateTime.AddDays(2); Console.Write("Saturday - Next working day: "); } else if (dateTime.DayOfWeek == DayOfWeek.Sunday) { dateTime = dateTime.AddDays(1); Console.Write("Sunday - Next working day: "); } else { Console.Write("Working day: "); } return(NextDay.GetNextDay(dateTime)); }