/// <summary> /// Updates (drifts) a ZonedDateTime value within specified range defined /// </summary> /// <param name="value">a DateTime value to drift.</param> /// <param name="range">(optional) a range in milliseconds. Default: 10 days</param> /// <returns>an updated DateTime and time value.</returns> public static DateTime UpdateDateTime(DateTime value, long range) { range = range != 0 ? range : 10L * 24 * 36000000; if (range < 0) { return(value); } var diff = RandomLong.NextLong(-range, range); return(value.AddMilliseconds(diff)); }
/// <summary> /// Generates a random TimeSpan in the range ['minTime', 'maxTime']. /// </summary> /// <param name="min">minimum range value</param> /// <param name="max">max range value</param> /// <returns>a random TimeSpan value.</returns> public static TimeSpan NextTime(long min, long max) { var duration = RandomLong.NextLong(min, max); return(TimeSpan.FromMilliseconds(duration)); }