Beispiel #1
0
 public DateInterval(DateTime start, DateTime end)
 {
     _start = start;
     _end   = end;
     ValidateStartIsBeforeEnd();
     _dateDisplayFormat = GetDateDisplayFormat();
 }
        public void When_DateToString_Then_DateIsProperlyDisplayed(string date, DateDisplayFormat format, string expectedDateString)
        {
            var dateTime = DateTime.Parse(date);

            var result = dateTime.ToString(format);

            Assert.AreEqual(expectedDateString, result);
        }
Beispiel #3
0
 public static string ToString(this DateTime dateTime, DateDisplayFormat format)
 {
     return(format switch
     {
         DateDisplayFormat.Day => dateTime.GetDayString(),
         DateDisplayFormat.DayMonth => dateTime.GetDayMonthString(),
         DateDisplayFormat.DayMonthYear => dateTime.GetDayMonthYearString(),
         _ => throw new ArgumentOutOfRangeException(nameof(format), format, "Inappropriate format.")
     });