public void Test3_TestDaysAcrossMonth_String(string InlineData, string expectedResult) { DayFinder test = new DayFinder(InlineData); test.Counter(); Assert.Equal(expectedResult, test.GetDayOfWeek()); }
public static string getDayInMonth(SYSTEMTIME st) { string sRet = ""; if (st.year != 0) { return(TimeClass.st2dateStr(st)); } //year must be zero //dayOfWeek: 0 = Sun, 1=Mon ... //wDay = 1: first, 2: second, 3: third, 4: fourth, 5: last //ie dayOfWeek=0 => Sunday //wDay = 5 => last dayOfWeek(here=Sunday) in month DateTime dt = new DateTime(DateTime.Now.Year, st.month, 1, st.hour, st.minute, st.second); DateTime dtSavings = new DateTime(); dtSavings = dt; if (st.day == 5) //last occurence of ??? in month { dtSavings = LastDayOfWeekInMonth(dt, (DayOfWeek)(st.dayOfWeek)); } else { int day = DayFinder.FindDay(DateTime.Now.Year, st.month, (DayOfWeek)(st.dayOfWeek), st.day); dtSavings = new DateTime(DateTime.Now.Year, st.month, day, st.hour, st.minute, st.second); } sRet = String.Format("{0:D4}.{1:D2}.{2:D2} {3:D2}:{4:D2}:{5:D2}", dtSavings.Year, dtSavings.Month, dtSavings.Day, dtSavings.Hour, dtSavings.Minute, dtSavings.Second); return(sRet); }
public void Test3_TestSundaysInOneMonth_String(string InlineData) { DayFinder test = new DayFinder(InlineData); test.Counter(); Assert.Equal("Sunday", test.GetDayOfWeek()); }
public void Test2_Counter_ReturnInt() { DayFinder test = new DayFinder("1/1/2000"); test.Counter(); Assert.Equal(36524, test.GetDaysSinceEpoch()); }
public void Test3_TestDaysAcrossYear_String(string InlineData, string expectedResult) { DayFinder test = new DayFinder(InlineData); test.Counter(); System.Console.WriteLine("Days since epoch: " + test.GetDaysSinceEpoch()); Assert.Equal(expectedResult, test.GetDayOfWeek()); }
public void returnsTheTemperatureDifferenceOfASingleLine() { //arrange string singleLine = " 4 77 59 68 51.1 0.00 110 9.1 130 12 8.6 62 40 1021.1"; // act int difference = DayFinder.temperatureDifferenceFromLine(singleLine); // assert Assert.AreEqual(18, difference); }
public void returnsTheDayOfASingleLine() { //arrange string singleLine = " 4 77 59 68 51.1 0.00 110 9.1 130 12 8.6 62 40 1021.1"; // act int day = DayFinder.dayFromLine(singleLine); // assert Assert.AreEqual(4, day); }
public HomeModule() { Get["/"] = _ => View["index.cshtml"]; //Insert your GETs and POSTs here Post["/find-weekday"] = _ => { string date = Request.Form["date"]; DayFinder newDayFinder = new DayFinder(date); newDayFinder.Counter(); return(View["index.cshtml", newDayFinder.GetDayOfWeek()]); }; }
public void returnsTheFirstDayOfATwoDayMonth() { //arrange string fileContent = " 4 77 76 68 51.1 0.00 110 9.1 130 12 8.6 62 40 1021.1\n" + " 5 90 88 78 68.3 0.00 TFH 220 8.3 260 12 6.9 84 55 1014.4"; // act int day = DayFinder.dayWithMinimalTemperatureRange(fileContent); // assert Assert.AreEqual(4, day); }
public void returnsTheFirstDayOfAThreeDayMonth() { //arrange string fileContent = " 6 81 61 71 63.7 0.00 RFH 030 6.2 030 13 9.7 93 60 1012.7\n" + " 7 73 72 65 53.0 0.00 RF 050 9.5 050 17 5.3 90 48 1021.8\n" + " 8 75 54 65 50.0 0.00 FH 160 4.2 150 10 2.6 93 41 1026.3"; // act int day = DayFinder.dayWithMinimalTemperatureRange(fileContent); // assert Assert.AreEqual(7, day); }
public void Test1_CheckLeapYear_True() { DayFinder test = new DayFinder("12/14/2004"); Assert.Equal(true, test.IsLeapYear(2004)); }
public static List <PublicHoliday> Get(DateTime easterSunday, int year) { //Switzerland var countryCode = "CH"; //In canton of Neuchâtel the following dates are considered official county holidays only if Christmas day and new year's day fall on a Sunday : 26.12 and 02.01 DateTime christmasDate = new DateTime(year, 12, 25); DateTime newYearDate = new DateTime(year, 12, 25); bool isChristmasDateSunday = christmasDate.DayOfWeek == DayOfWeek.Sunday; bool isNewYearDateSunday = newYearDate.DayOfWeek == DayOfWeek.Sunday; //Get Jeune fédéral holiday date for the given year (3rd monday of September) int thirdMondayOfSeptember = DayFinder.FindDay(year, 9, DayOfWeek.Monday, 3); var items = new List <PublicHoliday>(); //http://de.wikipedia.org/wiki/Feiertage_in_der_Schweiz items.Add( new PublicHoliday(1, 1, year, "Neujahr", "New Year's Day", countryCode, 1967)); items.Add( new PublicHoliday(2, 1, year, "Berchtoldstag", "St. Berchtold's Day", countryCode, null, new string[] { "CH-ZH", "CH-BE", "CH-LU", "CH-OW", "CH-GL", "CH-ZG", "CH-FR", "CH-SO", "CH-SH", "CH-TG", "CH-VD", "CH-NE", "CH-GE", "CH-JU" }, isNewYearDateSunday)); items.Add( new PublicHoliday(6, 1, year, "Heilige Drei Könige", "Epiphany", countryCode, null, new string[] { "CH-UR", "CH-SZ", "CH-GR", "CH-TI" })); items.Add( new PublicHoliday(1, 3, year, "Josefstag", "Saint Joseph's Day", countryCode, null, new string[] { "CH-NE" })); items.Add( new PublicHoliday(19, 3, year, "Josefstag", "Saint Joseph's Day", countryCode, null, new string[] { "CH-LU", "CH-UR", "CH-SZ", "CH-NW", "CH-ZG", "CH-GR", "CH-TI", "CH-VS" })); items.Add( new PublicHoliday(easterSunday.AddDays(-2), "Karfreitag", "Good Friday", countryCode, null, new string[] { "CH-ZH", "CH-BE", "CH-LU", "CH-UR", "CH-SZ", "CH-OW", "CH-NW", "CH-GL", "CH-ZG", "CH-FR", "CH-SO", "CH-BS", "CH-BL", "CH-SH", "CH-AR", "CH-AI", "CH-SG", "CH-GR", "CH-AG", "CH-TG", "CH-VD", "CH-NE", "CH-GE", "CH-JU" })); items.Add( new PublicHoliday(easterSunday.AddDays(1), "Ostermontag", "Easter Monday", countryCode, 1642, new string[] { "CH-ZH", "CH-BE", "CH-LU", "CH-UR", "CH-SZ", "CH-OW", "CH-NW", "CH-GL", "CH-ZG", "CH-FR", "CH-SO", "CH-BS", "CH-BL", "CH-SH", "CH-AR", "CH-AI", "CH-SG", "CH-GR", "CH-AG", "CH-TG", "CH-TI", "CH-VD", "CH-NE", "CH-GE", "CH-JU" }, false)); items.Add( new PublicHoliday(1, 5, year, "Tag der Arbeit", "Labor Day", countryCode, null, new string[] { "CH-ZH", "CH-FR", "CH-SO", "CH-BS", "CH-BL", "CH-SH", "CH-AG", "CH-TG", "CH-TI", "CH-NE", "CH-JU" })); items.Add( new PublicHoliday(easterSunday.AddDays(39), "Auffahrt", "Ascension Day", countryCode)); items.Add( new PublicHoliday(easterSunday.AddDays(40), "Auffahrt Freitag", "Ascension Friday", countryCode, null, new string[] { "CH-NE" }, false)); items.Add( new PublicHoliday(easterSunday.AddDays(50), "Pfingstmontag", "Whit Monday", countryCode, null, new string[] { "CH-ZH", "CH-BE", "CH-LU", "CH-UR", "CH-SZ", "CH-OW", "CH-NW", "CH-GL", "CH-ZG", "CH-FR", "CH-SO", "CH-BS", "CH-BL", "CH-SH", "CH-AR", "CH-AI", "CH-SG", "CH-GR", "CH-AG", "CH-TG", "CH-TI", "CH-VD", "CH-NE", "CH-GE", "CH-JU" }, false)); items.Add( new PublicHoliday(easterSunday.AddDays(60), "Fronleichnam", "Corpus Christi", countryCode, null, new string[] { "CH-LU", "CH-UR", "CH-SZ", "CH-OW", "CH-NW", "CH-ZG", "CH-FR", "CH-SO", "CH-BL", "CH-AI", "CH-GR", "CH-AG", "CH-TI", "CH-VS", "CH-JU" })); items.Add( new PublicHoliday(1, 8, year, "Bundesfeier", "Swiss National Day", countryCode)); items.Add( new PublicHoliday(15, 8, year, "Maria Himmelfahrt", "Assumption of the Virgin Mary", countryCode, null, new string[] { "CH-LU", "CH-UR", "CH-SZ", "CH-OW", "CH-NW", "CH-ZG", "CH-FR", "CH-SO", "CH-BL", "CH-AI", "CH-GR", "CH-AG", "CH-TI", "CH-VS", "CH-JU" })); items.Add( new PublicHoliday(thirdMondayOfSeptember, 9, year, "Jeûne Fédéral", "Jeûne Fédéral", countryCode, null, new string[] { "CH-NE", "CH-VD" }, false)); items.Add( new PublicHoliday(1, 11, year, "Allerheiligen", "All Saints' Day", countryCode, null, new string[] { "CH-LU", "CH-UR", "CH-SZ", "CH-OW", "CH-NW", "CH-GL", "CH-ZG", "CH-FR", "CH-SO", "CH-AI", "CH-SG", "CH-GR", "CH-AG", "CH-TI", "CH-VS", "CH-JU" })); items.Add( new PublicHoliday(8, 12, year, "Mariä Empfängnis", "Immaculate Conception", countryCode, null, new string[] { "CH-LU", "CH-UR", "CH-SZ", "CH-OW", "CH-NW", "CH-ZG", "CH-FR", "CH-SO", "CH-AI", "CH-GR", "CH-AG", "CH-TI", "CH-VS" })); items.Add( new PublicHoliday(24, 12, year, "Weihnachtsfrieden", "Christmas eve", countryCode, null, new string[] { "CH-NE" }, false)); items.Add( new PublicHoliday(25, 12, year, "Weihnachten", "Christmas Day", countryCode)); items.Add( new PublicHoliday(26, 12, year, "Stephanstag", "Boxing Day", countryCode, null, new string[] { "CH-NE" }, isChristmasDateSunday)); items.Add( new PublicHoliday(31, 12, year, "Silvester", "Silvester", countryCode, null, new string[] { "CH-NE" }, false)); return(items); }