Esempio n. 1
0
 public static IEnumerable <DateTime> StepTo(this DateTime from, DateTime to, MonthUnit step)
 {
     if (step.Months > 0L)
     {
         var limit = (DateTime.MaxValue - step).AddTicks(1L);
         if (limit > to)
         {
             limit = to;
         }
         for (; from < limit; from += step)
         {
             yield return(from);
         }
         if (from <= to)
         {
             yield return(from);
         }
     }
     else if (step.Months < 0L)
     {
         var limit = (DateTime.MinValue - step).AddTicks(-1L);
         if (limit < to)
         {
             limit = to;
         }
         for (; from > limit; from += step)
         {
             yield return(from);
         }
         if (from >= to)
         {
             yield return(from);
         }
     }
     else
     {
         throw new ArgumentException("step cannot be zero");
     }
 }
Esempio n. 2
0
 public static DateTime From(this MonthUnit months, DateTime dateTime)
 {
     return(dateTime + months);
 }
Esempio n. 3
0
 public static DateTime Before(this MonthUnit months, DateTime dateTime)
 {
     return(dateTime - months);
 }
Esempio n. 4
0
 public static DateTime FromNow(this MonthUnit months)
 {
     return(DateTime.Today + months);
 }
Esempio n. 5
0
 public static DateTime Ago(this MonthUnit months)
 {
     return(DateTime.Today - months);
 }