Пример #1
0
        /// <summary>
        /// Generates a random DateTime in the range ['minYear', 'maxYear']. This
        /// method generate dates without time(or time set to 00:00:00)
        /// </summary>
        /// <param name="min">(optional) minimum range value</param>
        /// <param name="max">max range value</param>
        /// <returns>a random DateTime value.</returns>
        public static DateTime NextDate(DateTime min, DateTime max)
        {
            var diff = RandomDouble.NextDouble(max.Subtract(min).TotalSeconds);
            var date = min.AddSeconds(diff);

            return(new DateTime(date.Year, date.Month, date.Day, 0, 0, 0, 0, min.Kind));
        }
Пример #2
0
        /// <summary>
        /// Generates a random DateTime and time in the range ['minYear', 'maxYear'].
        /// This method generate dates without time(or time set to 00:00:00)
        /// </summary>
        /// <param name="min">minimum range value</param>
        /// <param name="max">max range value</param>
        /// <returns>a random DateTime value.</returns>
        public static DateTime NextDateTime(DateTime min, DateTime max)
        {
            var diff = RandomDouble.NextDouble(max.Subtract(min).TotalSeconds);

            return(min.AddSeconds(diff));
        }