public void JudgingStringIsNullableDateTimeSpanTypeByGenericTypeAndWithIgnoreCaseTest()
        {
            var          today = DateTime.Today.AddDays(-10);
            var          now   = DateTime.Now;
            DateTimeSpan span  = now - today;
            var          text0 = span.ToString("c");
            var          text1 = span.ToString("g");
            var          text2 = span.ToString("G");

            text0.Is <DateTimeSpan>(Context).ShouldBeTrue();
            text1.Is <DateTimeSpan>(Context).ShouldBeTrue();
            text2.Is <DateTimeSpan>(Context).ShouldBeTrue();

            text0.Is <DateTimeSpan?>(Context).ShouldBeTrue();
            text1.Is <DateTimeSpan?>(Context).ShouldBeTrue();
            text2.Is <DateTimeSpan?>(Context).ShouldBeTrue();

            text0.IsNullable <DateTimeSpan>(Context).ShouldBeTrue();
            text1.IsNullable <DateTimeSpan>(Context).ShouldBeTrue();
            text2.IsNullable <DateTimeSpan>(Context).ShouldBeTrue();

            text0.IsNullable <DateTimeSpan?>(Context).ShouldBeTrue();
            text1.IsNullable <DateTimeSpan?>(Context).ShouldBeTrue();
            text2.IsNullable <DateTimeSpan?>(Context).ShouldBeTrue();
        }
        public void JudgingStringIsNullableDateTimeSpanTypeWithIgnoreCaseTest()
        {
            var          type         = typeof(DateTimeSpan);
            var          nullableType = typeof(DateTimeSpan?);
            var          today        = DateTime.Today.AddDays(-10);
            var          now          = DateTime.Now;
            DateTimeSpan span         = now - today;
            var          text0        = span.ToString("c");
            var          text1        = span.ToString("g");
            var          text2        = span.ToString("G");

            text0.Is(type, Context).ShouldBeTrue();
            text1.Is(type, Context).ShouldBeTrue();
            text2.Is(type, Context).ShouldBeTrue();

            text0.Is(nullableType, Context).ShouldBeTrue();
            text1.Is(nullableType, Context).ShouldBeTrue();
            text2.Is(nullableType, Context).ShouldBeTrue();

            text0.IsNullable(type, Context).ShouldBeTrue();
            text1.IsNullable(type, Context).ShouldBeTrue();
            text2.IsNullable(type, Context).ShouldBeTrue();

            text0.IsNullable(nullableType, Context).ShouldBeTrue();
            text1.IsNullable(nullableType, Context).ShouldBeTrue();
            text2.IsNullable(nullableType, Context).ShouldBeTrue();
        }
        public void JudgingStringIsDateTimeSpanTypeByGenericTypeTest()
        {
            var          today = DateTime.Today.AddDays(-10);
            var          now   = DateTime.Now;
            DateTimeSpan span  = now - today;
            var          text0 = span.ToString("c");
            var          text1 = span.ToString("g");
            var          text2 = span.ToString("G");

            text0.Is <DateTimeSpan>().ShouldBeTrue();
            text1.Is <DateTimeSpan>().ShouldBeTrue();
            text2.Is <DateTimeSpan>().ShouldBeTrue();
        }
Ejemplo n.º 4
0
        public void Should_get_formatted_date()
        {
            var span = new DateTimeSpan(new DateTime(2000, 1, 1, 8, 30, 0),
                                        new DateTime(2000, 1, 1, 17, 0, 0), "cst");

            span.ToString().ShouldEqual("1/1/2000 8:30 - 5:00 PM cst");
        }
Ejemplo n.º 5
0
 string OrdinalDay(DateTimeSpan offset)
 {
     if (offset == null)
     {
         return("");
     }
     if (offset.Type != DateTimeSpanTypes.Days)
     {
         return(offset.ToString());
     }
     return(offset.Days.ToString() + "-й день");
 }
Ejemplo n.º 6
0
        string Interval(DateTimeSpan duration)
        {
            if (duration == null)
            {
                return("");
            }
            string days   = RusDeclension("day", duration.Days);
            string nights = RusDeclension("night", duration.Nights);
            string sep    = duration.Type == DateTimeSpanTypes.DaysAndNights ? " и " : "";
            string ret    = days + sep + nights;

            if (ret == "")
            {
                ret = duration.ToString();
            }
            return(ret);
        }