using System;
namespace API.Extensions;
public static class DateTimeExtensions
{
    /// 
    /// Truncates a DateTime to a specified resolution.
    /// A convenient source for resolution is TimeSpan.TicksPerXXXX constants.
    /// 
    /// The DateTime object to truncate
    /// e.g. to round to nearest second, TimeSpan.TicksPerSecond
    /// Truncated DateTime
    public static DateTime Truncate(this DateTime date, long resolution)
    {
        return new DateTime(date.Ticks - (date.Ticks % resolution), date.Kind);
    }
}