<commit_before>﻿using System;

namespace Impromptu
{
    public static class Extensions
    {

        #region Public Static Methods

        /// <summary>
        /// Change type cast
        /// </summary>
        /// <param name="item">item to change</param>
        /// <typeparam name="T">change type to</typeparam>
        /// <remarks>Result of wanted to do dynamic cast to type of object</remarks>
        public static T Cast<T>(this object item)
        {
            return (T)Convert.ChangeType(item, typeof(T));
        }

        public static double NextDouble(this Random random, double min, double max)
        {
            return min + (random.NextDouble() * (max - min));
        }

        public static byte[] ToByteArray(this string value)
        {
            var encoding = new System.Text.UTF8Encoding();
            return value != null ? encoding.GetBytes(value) : null;
        }

        public static bool Equals(this DateTime dateTime1, DateTime dateTime2)
        {
            const int EPSILON = 1000;
            var result = System.Math.Abs(System.Math.Abs((dateTime1 - dateTime2).TotalMilliseconds)) < EPSILON;
            return result;
        }

        #endregion

    }
}
<commit_msg>closest date extension for arrary of dates<commit_after>﻿using System;
using System.Linq;

namespace Impromptu
{
    public static class Extensions
    {

        #region Public Static Methods

        /// <summary>
        /// Change type cast
        /// </summary>
        /// <param name="item">item to change</param>
        /// <typeparam name="T">change type to</typeparam>
        /// <remarks>Result of wanted to do dynamic cast to type of object</remarks>
        public static T Cast<T>(this object item)
        {
            return (T)Convert.ChangeType(item, typeof(T));
        }

        public static double NextDouble(this Random random, double min, double max)
        {
            return min + (random.NextDouble() * (max - min));
        }

        public static byte[] ToByteArray(this string value)
        {
            var encoding = new System.Text.UTF8Encoding();
            return value != null ? encoding.GetBytes(value) : null;
        }

        public static bool Equals(this DateTime dateTime1, DateTime dateTime2)
        {
            const int EPSILON = 1000;
            var result = System.Math.Abs(System.Math.Abs((dateTime1 - dateTime2).TotalMilliseconds)) < EPSILON;
            return result;
        }

        public static DateTime Closest(this DateTime[] datetimes, DateTime nearest)
        {
            return datetimes.OrderBy(t => System.Math.Abs((t - nearest).Ticks)).FirstOrDefault;
        }

        #endregion

    }
}

{'fraction_non_alphanumeric': 0.10499075785582256, 'fraction_numerical': 0.006654343807763401, 'mean_word_length': 1.963855421686747, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2606621', 'n_tokens_mistral': 740, 'n_tokens_neox': 713, 'n_words': 210}