Esempio n. 1
0
        public void Can_Format_Seconds(int seconds, string expected, string cultureName)
        {
            using (var context = new CultureSwitchContext(new CultureInfo(cultureName)))
            {
                var date   = DateTime.Now.AddSeconds(seconds);
                var pretty = new PrettyTime();

                var result = pretty.Format(date);

                Assert.NotNull(result);
                Assert.AreEqual(expected, result);
            }
        }
Esempio n. 2
0
        static void testPrettyTime()
        {
            var st2   = PrettyTime.Format(DateTime.Now.AddDays(1).AddHours(1));
            var st32  = PrettyTime.Format(DateTime.Now.AddHours(23));
            var st22  = PrettyTime.Format(DateTime.Now.AddDays(2));
            var st356 = PrettyTime.Format(DateTime.Now.AddHours(33));

            var st3  = PrettyTime.Format(DateTime.Now.AddHours(-23));
            var st   = PrettyTime.Format(DateTime.Now.AddDays(-1));
            var st4  = PrettyTime.Format(DateTime.Now.AddDays(-2));
            var st35 = PrettyTime.Format(DateTime.Now.AddHours(-33));

            Console.WriteLine();
        }
Esempio n. 3
0
        public void Can_Format_Years(int years, string expected, string cultureName)
        {
            using (var context = new CultureSwitchContext(new CultureInfo(cultureName)))
            {
                var datetime = DateTime.Now;
                var then     = DateTime.Now.AddYears(years);
                var pretty   = new PrettyTime(datetime);

                var result = pretty.Format(then);

                Assert.NotNull(result);
                Assert.AreEqual(expected, result);
            }
        }
Esempio n. 4
0
 public static string AsPrettyString(this TimeSpan time)
 {
     return(PrettyTime.Format(time));
 }
Esempio n. 5
0
 public static string AsPrettyString(this DateTime date)
 {
     return(PrettyTime.Format(date));
 }
 public static string ToPrettyTime(this DateTime date)
 {
     var pretty = new PrettyTime();
     return pretty.Format(date);
 }
Esempio n. 7
0
        public static string ToPrettyTime(this DateTime date)
        {
            var pretty = new PrettyTime();

            return(pretty.Format(date));
        }