public IActionResult Get(string date) { string[] dateArr = date.Split(' '); string year = dateArr.Length > 1 ? dateArr[1] : ""; if (year.Length == 0) { return(new BadRequestResult()); } DateTime dateTime = Convert.ToDateTime(date); while (DateSystem.IsPublicHoliday(dateTime, CountryCode.CZ) || DateSystem.IsWeekend(dateTime, CountryCode.CZ)) { dateTime = dateTime.AddDays(-1); } List <Currency> result = database.GetCollection <Currency>(dateTime.Year.ToString()).Find(a => true).ToList(); if (result.Count > 0) { return(new OkObjectResult(result)); } else { return(new NotFoundResult()); } }
public void TestUnitedKingdom() { var testDate = new DateTime(2017, 08, 28); var isPublicHoliday = DateSystem.IsPublicHoliday(testDate, CountryCode.GB, "GB-ENG"); Assert.AreEqual(true, isPublicHoliday); }
public DateTime addHolidays(DateTime beforeDateTime, DateTime afterDateTime) { CountryCode a = new CountryCode(); a = CountryCode.NO; DateTime newDate = afterDateTime; if (afterDateTime.DayOfWeek == DayOfWeek.Sunday) { afterDateTime = afterDateTime.AddDays(1); } if (afterDateTime.DayOfWeek == DayOfWeek.Saturday) { afterDateTime = afterDateTime.AddDays(2); } if (DateSystem.IsPublicHoliday(afterDateTime, a)) { afterDateTime = afterDateTime.AddDays(1); } while (beforeDateTime.Day != afterDateTime.Day) { if (beforeDateTime.DayOfWeek == DayOfWeek.Sunday || beforeDateTime.DayOfWeek == DayOfWeek.Saturday || DateSystem.IsPublicHoliday(beforeDateTime, a)) { //Console.WriteLine(beforeDateTime); newDate = newDate.AddDays(1); } beforeDateTime = beforeDateTime.AddDays(1); } //Console.ReadKey(); return(newDate); }
public void TestIsleOfMan() { var testDate = new DateTime(2017, 08, 28); var isPublicHoliday = DateSystem.IsPublicHoliday(testDate, CountryCode.IM); Assert.AreEqual(true, isPublicHoliday); }
private void CountStawki() { var startDate = CalendarStawki.DisplayDate.AddDays(-CalendarStawki.DisplayDate.Day + 1); var endTime = startDate.AddMonths(1).AddDays(-1); var currentMonth = DateSystem.GetPublicHoliday(CountryCode.PL, startDate, endTime); Stawki.Text = "Urlopy: " + string.Join(", ", CalendarStawki.SelectedDates.Select(x => x.ToString("M"))); Swieta.Text = "Swieta: " + string.Join(", ", currentMonth.Select(x => x.Date.ToString("M"))); double payment; var workingDays = 0; if (double.TryParse(Payment.Text, out payment)) { foreach (var day in EachDay(startDate, endTime)) { if (day.DayOfWeek != DayOfWeek.Saturday && day.DayOfWeek != DayOfWeek.Sunday) { if (!DateSystem.IsPublicHoliday(day, CountryCode.PL)) { if (!CalendarStawki.SelectedDates.Any(x => x.Date == day.Date)) { workingDays++; } } } } var perHour = payment / (workingDays * (7 + ((double)35 / (double)60))); ResultStawki.Text = $"Dni pracujące w miesiącu {startDate:MMMM}: {workingDays}\r\nStawka godzinowa: {perHour:0.##}"; } }
private void QAVAssert(QAVTest test, object actual) { /* If a date specific argument was given and the BestMatch option was set to false, * then stock info may not available when trading date is on weekend or a public holiday.*/ if ((test.DatePart < 0 || test.QuoteDate != default(DateTime)) && !test.BestMatch) { DateTime tradingDate = DateTime.Today.AddDays(test.DatePart); if (tradingDate.DayOfWeek == DayOfWeek.Saturday || tradingDate.DayOfWeek == DayOfWeek.Sunday || DateSystem.IsPublicHoliday(tradingDate, CountryCode.US)) { // No quotes are available on the weekend or on public holidays. Assert.True(ExcelError.ExcelErrorNA.Equals(actual) || actual is decimal); } } else { // For current trading dates only test on type is possible. switch (test.Info) { case "volume": Assert.True(int.TryParse(actual.ToString(), out int value)); break; default: Assert.IsType <decimal>(actual); break; } } }
public ActionResult <IEnumerable <PublicHolidayDto> > IsTodayPublicHoliday( [FromRoute][Required] string countryCode, [FromQuery] string countyCode) { if (!Enum.TryParse(countryCode, true, out CountryCode parsedCountryCode)) { return(StatusCode(StatusCodes.Status404NotFound)); } if (string.IsNullOrEmpty(countyCode)) { if (DateSystem.IsPublicHoliday(DateTime.Today, parsedCountryCode)) { return(StatusCode(StatusCodes.Status200OK)); } return(StatusCode(StatusCodes.Status204NoContent)); } if (DateSystem.IsPublicHoliday(DateTime.Today, parsedCountryCode, countyCode)) { return(StatusCode(StatusCodes.Status200OK)); } return(StatusCode(StatusCodes.Status204NoContent)); }
public bool storeSerie(DateTime primogiorno, int settimane, List <DayOfWeek> listaGiorni, DateTime orarioI, DateTime orarioF, string nome, string cognome, string email) { Cliente cliente = new Cliente(nome, cognome, email); int clienteID = _repository.storeCliente(cliente); var appuntamenti = _repository.getAllAppuntamenti(); DateTime gg = primogiorno; int numapp = listaGiorni.Count * settimane; int cont = 0; while (cont < numapp) { if (listaGiorni.Contains(gg.DayOfWeek)) { if (!appuntamenti.Any(i => !i.compatibile(new DateTime(gg.Year, gg.Month, gg.Day, orarioI.Hour, orarioI.Minute, 0), new DateTime(gg.Year, gg.Month, gg.Day, orarioF.Hour, orarioF.Minute, 0)))) { if (!DateSystem.IsPublicHoliday(gg, CountryCode.IT)) { cont++; Appuntamento app = new Appuntamento(new DateTime(gg.Year, gg.Month, gg.Day, orarioI.Hour, orarioI.Minute, 0), new DateTime(gg.Year, gg.Month, gg.Day, orarioF.Hour, orarioF.Minute, 0), clienteID); _repository.storeAppuntamento(app); } } } gg = gg.AddDays(1); } return(true); }
public List <DateTime> WorkDayList() { int year, month; year = Convert.ToInt32(textBox_Year.Text); month = Convert.ToInt32(textBox_Month.Text); var ignoreDays = listBox_IgnoreDays.Items.Cast <string>().ToArray(); var result = new List <DateTime>(); var lastDay = DateTime.DaysInMonth(year, month); for (int day = 1; day < lastDay; day++) { var date = new DateTime(year, month, day); if (checkBox_publicHoliday.Checked) { if (DateSystem.IsPublicHoliday(date, CountryCode.KR)) { continue; } } if (DateSystem.IsWeekend(date, CountryCode.KR)) { continue; } else if (ignoreDays.Contains(day + "")) { continue; } result.Add(date); } return(result); }
public void TestUnitedKingdomStPatricksDay() { var testDate = new DateTime(2017, 03, 17); var isPublicHoliday = DateSystem.IsPublicHoliday(testDate, CountryCode.GB, "GB-NIR"); Assert.AreEqual(true, isPublicHoliday); }
public IActionResult Get(string date) { string[] dateArr = date.Split(' '); string year = dateArr.Length > 1 ? dateArr[1] : ""; if (year.Length == 0) { return(new BadRequestResult()); } DateTime dateTime = Convert.ToDateTime(date); while (DateSystem.IsPublicHoliday(dateTime, CountryCode.CZ) || DateSystem.IsWeekend(dateTime, CountryCode.CZ)) { dateTime = dateTime.AddDays(-1); } date = dateTime.ToString("dd.MMM yyyy"); //Convert back for comparison List <ExchangeRate> result = database.GetCollection <ExchangeRate>(dateTime.Year.ToString()).Find(a => a.date == date).ToList(); if (result.Count > 0) { return(new OkObjectResult(result[0])); } else { return(new NotFoundResult()); } }
private void SetCalendar() { _lsDays = new List <CBDay>(); var date = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); lblYear.Content = DateTime.Now.Year; lblMonth.Content = DateTime.Now.ToString("MMMM", new CultureInfo("en-US")).ToUpper(); var lastDay = date.AddMonths(1).AddDays(-1).Day; for (int i = 1; i <= lastDay; i++) { var day = new CBDay { Day = i }; if (date.DayOfWeek == DayOfWeek.Sunday || DateSystem.IsPublicHoliday(date, CountryCode.US)) { day.Foreground = "Red"; } date = date.AddDays(1); _lsDays.Add(day); } lvCalendar.ItemsSource = _lsDays; SetToday(); }
private void SetCalendarDays(int month, int year) { SuspendLayout(); try { ClearCalendarDays(); AddOffsetDays(year, month); int daysInCurrentMonth = DateTime.DaysInMonth(year, month); for (int i = 1; i <= daysInCurrentMonth; i++) { DateTime date = new DateTime(year, month, i); DayData dayData = new DayData { Day = i, IsWeekend = date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday, IsHoliday = DateSystem.IsPublicHoliday(date, CountryCode.ES) }; DayControl dayControl = new DayControl(dayData); _daysControls.Add(dayControl); flowLayoutPanel.Controls.Add(dayControl); } } finally { ResumeLayout(); } }
public ActionResult IsTodayPublicHoliday( [FromRoute][Required] string countryCode, [FromQuery] string countyCode, [FromQuery][Range(-12, 12)] int offset = 0) { if (!Enum.TryParse(countryCode, true, out CountryCode parsedCountryCode)) { return(StatusCode(StatusCodes.Status404NotFound)); } if (string.IsNullOrEmpty(countyCode)) { if (DateSystem.IsPublicHoliday(DateTime.UtcNow.AddHours(offset), parsedCountryCode)) { return(StatusCode(StatusCodes.Status200OK)); } return(StatusCode(StatusCodes.Status204NoContent)); } if (DateSystem.IsPublicHoliday(DateTime.UtcNow.AddHours(offset), parsedCountryCode, countyCode)) { return(StatusCode(StatusCodes.Status200OK)); } return(StatusCode(StatusCodes.Status204NoContent)); }
public void TestBrazilSPRevolutionOf1932(string countyCode, bool expected) { var testDate = new DateTime(2022, 07, 09); var isPublicHoliday = DateSystem.IsPublicHoliday(testDate, CountryCode.BR, countyCode); Assert.AreEqual(expected, isPublicHoliday); }
public void TestBrazil() { var testDate = new DateTime(2022, 10, 12); var isPublicHoliday = DateSystem.IsPublicHoliday(testDate, CountryCode.BR); Assert.AreEqual(true, isPublicHoliday); }
//B19443_ChangesToPluginFunctionality MGY 2018.05.24 private bool isPublicHoliday(Outlook.AppointmentItem appt) { CountryCode countryCode = CountryCode.NL; switch (this.CompanyCountry) { case "NL": countryCode = CountryCode.NL; break; case "BE": countryCode = CountryCode.BE; break; case "DK": countryCode = CountryCode.DK; break; case "ES": countryCode = CountryCode.ES; break; case "DE": countryCode = CountryCode.DE; break; default: countryCode = CountryCode.NL; break; } return(DateSystem.IsPublicHoliday(appt.Start, countryCode) || (appt.Start.DayOfWeek == DayOfWeek.Saturday) || (appt.Start.DayOfWeek == DayOfWeek.Sunday)); }
private int GetWorkingDaysOfMonth(DateTime date) { DayOfWeek[] weekends = { DayOfWeek.Saturday, DayOfWeek.Sunday }; var remainingDates = Enumerable.Range(1, DateTime.DaysInMonth(date.Year, date.Month)) .Select(day => new DateTime(date.Year, date.Month, day)); return(remainingDates.Count(e => !weekends.Contains(e.DayOfWeek) && !DateSystem.IsPublicHoliday(e, CountryCode.PL))); }
public static bool hday(DateTime date) { if (DateSystem.IsPublicHoliday(date, CountryCode.US)) { return(true); } return(false); }
public void TestGermanyIsOfficialPublicHolidayByCountyWithCountySpecificEpiphany2017() { var isPublicHolidayInBW = DateSystem.IsPublicHoliday(new DateTime(2017, 1, 6), CountryCode.DE, "DE-BW"); var isPublicHolidayInNW = DateSystem.IsPublicHoliday(new DateTime(2017, 1, 6), CountryCode.DE, "DE-NW"); Assert.IsTrue(isPublicHolidayInBW); Assert.IsFalse(isPublicHolidayInNW); }
public void CheckMayDay(int year, int month, int day, bool expected) { var date = new DateTime(year, month, day); var result = DateSystem.IsPublicHoliday(date, CountryCode.GB); Assert.AreEqual(expected, result); }
public void Run() { Random rnd = new Random(); int schoolvakantie = rnd.Next(0, 1); int file = rnd.Next(0, 1); DateTime maand_jaar = GetRandomDate(); List <string> kwartieren = GenerateListKwartieren(); string module = "lunch"; int keuze = 0; DB.OpenCon(); DateTime d; string convert_maand = ""; int amount_of_people = 0; int max = 50000; for (int i = 0; i < max; i++) { // After save generate_new_ids schoolvakantie = rnd.Next(0, 2); file = rnd.Next(0, 2); maand_jaar = GetRandomDate(); kwartieren = GenerateListKwartieren(); keuze = rnd.Next(0, kwartieren.Count()); kwartieren.ElementAt(keuze); var temp = kwartieren[keuze]; maand_jaar = maand_jaar.Add(TimeSpan.Parse(temp)); convert_maand = String.Format("{0:yyyy-MM-dd:HH:mm}", maand_jaar); int hours = maand_jaar.Hour; if ((hours >= 8 && hours <= 10) || (hours) == 18 || (hours == 17)) { file = 1; amount_of_people = rnd.Next(0, 20); } else { file = 0; amount_of_people = rnd.Next(20, 50); } if (DateSystem.IsPublicHoliday(maand_jaar, CountryCode.NL)) { schoolvakantie = 1; } else { schoolvakantie = 0; } Console.WriteLine("Record verwerkt" + i + "/ " + max); DB.QueryInsert <string>("INSERT INTO data_beacon(school_holiday,`file`,`dt_created`,`module`,`amount_of_people`) VALUES " + "(" + schoolvakantie + "," + file + ",'" + convert_maand + "','" + module + "', " + amount_of_people + ")"); // Save results in DB } DB.CloseCon(); }
public void CheckIsPublicHoliday() { var isPublicHoliday = DateSystem.IsPublicHoliday(new DateTime(2016, 5, 1), CountryCode.AT); Assert.AreEqual(true, isPublicHoliday); isPublicHoliday = DateSystem.IsPublicHoliday(new DateTime(2016, 1, 6), CountryCode.AT); Assert.AreEqual(true, isPublicHoliday); }
public DateTime CalculateNextDueDate(DateTime date) { while (DateSystem.IsPublicHoliday(date, CountryCode.GB) || date.IsWeekend(CountryCode.GB)) { date = date.AddDays(1); } return(date); }
public bool IsWorkDay(DateTime workDay) { if (workDay.DayOfWeek == DayOfWeek.Saturday || workDay.DayOfWeek == DayOfWeek.Sunday || DateSystem.IsPublicHoliday(workDay, CountryCode.LT)) { return(false); } return(true); }
private bool IsFeeFreeDay(DateTime date) { if (DateSystem.IsPublicHoliday(date, CountryCode.SE)) { return(true); } return(false); }
public void CheckIsOfficialPublicHolidayByCounty1() { var isPublicHoliday = DateSystem.IsPublicHoliday(new DateTime(2019, 8, 5), CountryCode.AU); Assert.IsFalse(isPublicHoliday); isPublicHoliday = DateSystem.IsPublicHoliday(new DateTime(2019, 8, 5), CountryCode.AU, "AUS-NT"); Assert.IsTrue(isPublicHoliday); isPublicHoliday = DateSystem.IsPublicHoliday(new DateTime(2019, 8, 5), CountryCode.AU, "AUS-WA"); Assert.IsFalse(isPublicHoliday); }
private static void Test1() { var date = DateTime.Today; var countryCode = CountryCode.US; do { date = date.AddDays(1); } while (DateSystem.IsPublicHoliday(date, countryCode) || date.IsWeekend(countryCode)); }
//install-package Nager.Date public static bool IsHoliday(DateTime?d) { DateTime date = d.Value; if (DateSystem.IsPublicHoliday(date, CountryCode.US)) { return(true); } return(false); }
public void TestGermanyIsOfficialPublicHolidayByCountyWithCountySpecificWorldChildrensDay() { var isPublicHolidayInTH2018 = DateSystem.IsPublicHoliday(new DateTime(2018, 9, 20), CountryCode.DE, "DE-TH"); var isPublicHolidayInTH2019 = DateSystem.IsPublicHoliday(new DateTime(2019, 9, 20), CountryCode.DE, "DE-TH"); var isPublicHolidayInTH2020 = DateSystem.IsPublicHoliday(new DateTime(2020, 9, 20), CountryCode.DE, "DE-TH"); Assert.IsFalse(isPublicHolidayInTH2018); Assert.IsTrue(isPublicHolidayInTH2019); Assert.IsTrue(isPublicHolidayInTH2020); }