using Hotline.Share.Dtos.CallCenter;
using Novacode;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hotline.Share.Tools;
public static class DateTimeExtensions
{
    /// <summary>
    /// 获取两个时间之间的差
    /// </summary>
    /// <param name="beginDateTime">开始时间</param>
    /// <param name="endDateTime">结束时间</param>
    /// <returns>相距秒数</returns>
    public static int GetDifferenceSeconds(this DateTime beginDateTime, DateTime endDateTime)
    {
        return (int)(beginDateTime - endDateTime).TotalSeconds;
    }

    public static (DateTime, DateTime) DayStartAndEndTime(this DateTime dateTime)
    {
        var start = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day);
        var end = start.AddDays(1).AddTicks(-1);
        return (start, end);
    }

    public static string ToLongDateTimeString(this DateTime dateTime)
    { 
        return dateTime.ToString("yyyy-MM-dd HH:mm:ss");
    }

    public static long ToUnixTimeMilliseconds(this DateTime value)
    {
        return new DateTimeOffset(value).ToUnixTimeMilliseconds();
    }

}
