示例#1
0
 /// <summary>
 /// Aligns the date and time value to the upper boundary of a time span.
 /// </summary>
 /// <param name="value">The date and time value that needs to be snapped onto the interval span.</param>
 /// <param name="interval">The time series interval to align the date and time value onto.</param>
 /// <returns>The date and time value aligned to the upper time span boundary.</returns>
 public static DateTime?RoundUpper(this DateTime?value, SeriesInterval interval)
 {
     if (value != null)
     {
         return(value.Value.RoundUpper(interval.GetSpan().Ticks));
     }
     else
     {
         return(null);
     }
 }
示例#2
0
 /// <summary>
 /// Checks if the date and time value is after the reference point within specified number of intervals.
 /// </summary>
 /// <param name="source">The date and time reference point to check the vicinity for.</param>
 /// <param name="target">The date and time value to check the vicinity for.</param>
 /// <param name="interval">The time series interval to calculate the time span for.</param>
 /// <param name="count">The number of time series intervals to check around.</param>
 /// <returns>True if the requested date and time value is within the range after the point; otherwise, false.</returns>
 public static bool IsAfter(this DateTime source, DateTime target, SeriesInterval interval, int count)
 {
     return(target >= source + interval.GetSpan(count));
 }
示例#3
0
 /// <summary>
 /// Aligns the date and time value to the upper boundary of a time span.
 /// </summary>
 /// <param name="value">The date and time value that needs to be snapped onto the interval span.</param>
 /// <param name="interval">The time series interval to align the date and time value onto.</param>
 /// <returns>The date and time value aligned to the upper time span boundary.</returns>
 public static DateTime RoundUpper(this DateTime value, SeriesInterval interval)
 {
     return(value.RoundUpper(interval.GetSpan().Ticks));
 }
示例#4
0
 /// <summary>
 /// Checks if the date and time value is before the reference point within specified number of intervals.
 /// </summary>
 /// <param name="source">The date and time reference point to check the vicinity for.</param>
 /// <param name="target">The date and time value to check the vicinity for.</param>
 /// <param name="interval">The time series interval to calculate the time span for.</param>
 /// <returns>True if the requested date and time value is within the range before the point; otherwise, false.</returns>
 public static bool IsBefore(this DateTime source, DateTime target, SeriesInterval interval)
 {
     return(target <= source + interval.GetSpan());
 }