Example #1
0
        public static string Describe(this TimeSpan ts)
        {
            int[]    days      = new int[] { ts.Days, ts.Hours, ts.Minutes, ts.Seconds };
            int[]    numArray  = days;
            double[] totalDays = new double[] { ts.TotalDays, ts.TotalHours, ts.TotalMinutes, ts.TotalSeconds };
            double[] numArray1 = totalDays;
            var      variable  = ((IEnumerable <int>)numArray).Select((int value, int index) => new { @value = value, index = index }).FirstOrDefault((x) => x.@value != 0);

            if (variable == null)
            {
                return("now");
            }
            int    num  = variable.index;
            string str  = (num >= 3 ? string.Empty : "about ");
            int    num1 = (int)Math.Round(numArray1[num]);

            return(string.Concat(str, TimeExtensions._tense(num1, TimeExtensions.NAMES[num])));
        }
Example #2
0
 public static DateTimeOffset BeginningOfWeek(this DateTimeOffset dt)
 {
     return((dt - TimeExtensions.days(dt.DayOfWeek.DaysSince(Time.FirstDayOfWeek()))).BeginningOfDay());
 }
Example #3
0
 public static DateTimeOffset Previous(this DateTimeOffset dt, DayOfWeek nextDoW)
 {
     return(dt - TimeExtensions.days(dt.DayOfWeek.DaysSince(nextDoW)));
 }
Example #4
0
 public static DateTimeOffset Next(this DateTimeOffset dt, DayOfWeek nextDoW)
 {
     return(dt + TimeExtensions.days(dt.DayOfWeek.DaysTill(nextDoW)));
 }
Example #5
0
 public static DateTimeOffset EndOfWeek(this DateTimeOffset dt)
 {
     return((dt + TimeExtensions.days(dt.DayOfWeek.DaysTill(Time.LastDayOfWeek()))).endOfDay());
 }
Example #6
0
 public static int DaysTill(this DayOfWeek dt, DayOfWeek nextDoW)
 {
     dt.CheckRange();
     nextDoW.CheckRange();
     return(TimeExtensions.daysBetween((int)nextDoW, (int)dt));
 }
Example #7
0
 public static int DaysSince(this DayOfWeek dt, DayOfWeek prevDoW)
 {
     dt.CheckRange();
     prevDoW.CheckRange();
     return(TimeExtensions.daysBetween((int)dt, (int)prevDoW));
 }