Exemple #1
0
 public static DateTimeComponents And(this DateTimeComponents components, DateTimeComponents operand)
 {
     return new DateTimeComponents(components.Years + operand.Years
                                 , components.Months + operand.Months
                                 , components.Days + operand.Days
                                 , components.Minutes + operand.Minutes
                                 , components.Seconds + operand.Seconds
                                 , components.Milliseconds + operand.Milliseconds);
 }
Exemple #2
0
 /// <summary>
 /// Calculates the result of DateTimeComponents subtracted from a given DateTime.
 /// </summary>
 /// <param name="components"><see cref="DateTimeComponents"/> operand.</param>
 /// <param name="dateTime">DateTime operand from which to calculate a past date.</param>
 /// <returns>Past DateTime calculated from the given DateTimeComponents.</returns>
 public static DateTime AgoFrom(this DateTimeComponents components, DateTime dateTime)
 {
     return(dateTime.AddYears(-components.Years)
            .AddMonths(-components.Months)
            .AddDays(-components.Days)
            .AddMinutes(-components.Minutes)
            .AddSeconds(-components.Seconds)
            .AddMilliseconds(-components.Milliseconds));
 }
Exemple #3
0
 public static DateTimeComponents And(this DateTimeComponents components, DateTimeComponents operand)
 {
     return(new DateTimeComponents(components.Years + operand.Years
                                   , components.Months + operand.Months
                                   , components.Days + operand.Days
                                   , components.Minutes + operand.Minutes
                                   , components.Seconds + operand.Seconds
                                   , components.Milliseconds + operand.Milliseconds));
 }
Exemple #4
0
 /// <summary>
 /// Calculates the result of DateTimeComponents subtracted from DateTime.Now().
 /// </summary>
 /// <param name="components"><see cref="DateTimeComponents"/> operand.</param>
 /// <returns>Past DateTime calculated from DateTime.Now().</returns>
 public static DateTime Ago(this DateTimeComponents components)
 {
     return(components.AgoFrom(_nowAdapter.DateTimeNow()));
 }