Beispiel #1
0
 public AgeSpan(global::System.TimeSpan span)
 {
     this             = new AgeSpan();
     this.TotalYears  = span.GetTotalYears();
     this.Years       = span.GetYears();
     this.TotalMonths = span.GetTotalMonths();
     this.Months      = span.GetMonths();
     this.TotalWeeks  = span.GetTotalWeeks();
     this.Weeks       = span.GetWeeks();
     this.Days        = span.GetDays();
     this.TimeSpan    = span;
 }
        public static string ToApproximateAgeString(this DateTime fromDate)
        {
            AgeSpan age = fromDate.GetAge();

            if (Math.Abs(age.TotalMinutes) <= 1.0)
            {
                if (age.TotalSeconds <= 0.0)
                {
                    return("Right now");
                }
                return("Just now");
            }
            if (age.TotalSeconds > 0.0)
            {
                return(age.ToString(1, false, false) + " ago");
            }
            return(age.ToString(1, false, false) + " from now");
        }
Beispiel #3
0
        public static string ToWords(this TimeSpan span, bool shortForm, int maxParts)
        {
            AgeSpan span2 = new AgeSpan(span);

            return(span2.ToString(maxParts, shortForm, false));
        }