Просмотр исходного кода

移除一些几乎用不着的api

懒得勤快 5 лет назад
Родитель
Сommit
2eb9539020

+ 0 - 50
Masuit.Tools.Abstractions/Database/DataExt.cs

@@ -1,50 +0,0 @@
-using System;
-using System.Data;
-using System.Reflection;
-
-namespace Masuit.Tools.Database
-{
-    /// <summary>
-    /// SqlDataReader扩展类
-    /// </summary>
-    public static class DataExt
-    {
-        /// <summary>
-        /// 根据DataRow映射到实体模型
-        /// </summary>
-        /// <typeparam name="T">实体模型</typeparam>
-        /// <param name="row">数据行</param>
-        /// <returns>映射后的实体模型</returns>
-        public static T MapEntity<T>(this DataRow row) where T : class
-        {
-            T obj = Assembly.GetAssembly(typeof(T)).CreateInstance(typeof(T).FullName) as T;
-            Type type = typeof(T);
-            PropertyInfo[] properties = type.GetProperties();
-            foreach (PropertyInfo p in properties)
-            {
-                p.SetValue(obj, row[p.Name]);
-            }
-
-            return obj;
-        }
-
-        /// <summary>
-        /// 根据DataReader映射到实体模型
-        /// </summary>
-        /// <typeparam name="T">实体模型</typeparam>
-        /// <param name="dr">IDataReader</param>
-        /// <returns>映射后的实体模型</returns>
-        public static T MapEntity<T>(this IDataReader dr) where T : class
-        {
-            T obj = Assembly.GetAssembly(typeof(T)).CreateInstance(typeof(T).FullName) as T;
-            Type type = typeof(T);
-            PropertyInfo[] properties = type.GetProperties();
-            foreach (PropertyInfo p in properties)
-            {
-                p.SetValue(obj, dr[p.Name]);
-            }
-
-            return obj;
-        }
-    }
-}

+ 427 - 7
Masuit.Tools.Abstractions/DateTimeExt/DateTimeHelper.cs

@@ -1,13 +1,14 @@
-using System;
+using System;
+using System.Diagnostics;
 using System.Globalization;
 using System.Runtime.InteropServices;
 
 namespace Masuit.Tools.DateTimeExt
 {
     /// <summary>
-    /// 日期时间帮助
+    /// 日期操作工具
     /// </summary>
-    public static class DateTimeHelper
+    public static class DateUtil
     {
         /// <summary>
         /// 获取某一年有多少周
@@ -27,7 +28,7 @@ namespace Masuit.Tools.DateTimeExt
         /// </summary>
         /// <param name="date">时间</param>
         /// <returns>第几周</returns>
-        public static int WeekOfYear(this DateTime date)
+        public static int WeekOfYear(this in DateTime date)
         {
             var gc = new GregorianCalendar();
             return gc.GetWeekOfYear(date, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
@@ -39,7 +40,7 @@ namespace Masuit.Tools.DateTimeExt
         /// <param name="date">时间</param>
         /// <param name="week">一周的开始日期</param>
         /// <returns>第几周</returns>
-        public static int WeekOfYear(this DateTime date, DayOfWeek week)
+        public static int WeekOfYear(this in DateTime date, DayOfWeek week)
         {
             var gc = new GregorianCalendar();
             return gc.GetWeekOfYear(date, CalendarWeekRule.FirstDay, week);
@@ -103,7 +104,7 @@ namespace Masuit.Tools.DateTimeExt
         /// 设置本地计算机时间
         /// </summary>
         /// <param name="dt">DateTime对象</param>
-        public static void SetLocalTime(this DateTime dt)
+        public static void SetLocalTime(this in DateTime dt)
         {
             SystemTime st;
             st.year = (short)dt.Year;
@@ -118,5 +119,424 @@ namespace Masuit.Tools.DateTimeExt
         }
 
         #endregion
+        /// <summary>
+        /// 返回相对于当前时间的相对天数
+        /// </summary>
+        /// <param name="dt"></param>
+        /// <param name="relativeday">相对天数</param>
+        public static string GetDateTime(this in DateTime dt, int relativeday)
+        {
+            return dt.AddDays(relativeday).ToString("yyyy-MM-dd HH:mm:ss");
+        }
+
+        /// <summary>
+        /// 返回标准时间格式string
+        /// </summary>
+        public static string GetDateTimeF(this in DateTime dt) => dt.ToString("yyyy-MM-dd HH:mm:ss:fffffff");
+
+        /// <summary>
+        /// 获取该时间相对于1970-01-01 00:00:00的秒数
+        /// </summary>
+        /// <param name="dt"></param>
+        /// <returns></returns>
+        public static double GetTotalSeconds(this in DateTime dt) => new DateTimeOffset(dt).ToUnixTimeSeconds();
+
+        /// <summary>
+        /// 获取该时间相对于1970-01-01 00:00:00的毫秒数
+        /// </summary>
+        /// <param name="dt"></param>
+        /// <returns></returns>
+        public static double GetTotalMilliseconds(this in DateTime dt) => new DateTimeOffset(dt).ToUnixTimeMilliseconds();
+
+        /// <summary>
+        /// 获取该时间相对于1970-01-01 00:00:00的微秒时间戳
+        /// </summary>
+        /// <param name="dt"></param>
+        /// <returns></returns>
+        public static long GetTotalMicroseconds(this in DateTime dt) => new DateTimeOffset(dt).Ticks / 10;
+
+        /// <summary>
+        /// 获取该时间相对于1970-01-01 00:00:00的纳秒时间戳
+        /// </summary>
+        /// <param name="dt"></param>
+        /// <returns></returns>
+        public static long GetTotalNanoseconds(this in DateTime dt) => new DateTimeOffset(dt).Ticks * 100 + Stopwatch.GetTimestamp() % 100;
+
+        /// <summary>
+        /// 获取该时间相对于1970-01-01 00:00:00的分钟数
+        /// </summary>
+        /// <param name="dt"></param>
+        /// <returns></returns>
+        public static double GetTotalMinutes(this in DateTime dt) => new DateTimeOffset(dt).Offset.TotalMinutes;
+
+        /// <summary>
+        /// 获取该时间相对于1970-01-01 00:00:00的小时数
+        /// </summary>
+        /// <param name="dt"></param>
+        /// <returns></returns>
+        public static double GetTotalHours(this in DateTime dt) => new DateTimeOffset(dt).Offset.TotalHours;
+
+        /// <summary>
+        /// 获取该时间相对于1970-01-01 00:00:00的天数
+        /// </summary>
+        /// <param name="dt"></param>
+        /// <returns></returns>
+        public static double GetTotalDays(this in DateTime dt) => new DateTimeOffset(dt).Offset.TotalDays;
+
+        /// <summary>
+        /// 返回本年有多少天
+        /// </summary>
+        /// <param name="_"></param>
+        /// <param name="iYear">年份</param>
+        /// <returns>本年的天数</returns>
+        public static int GetDaysOfYear(this DateTime _, int iYear)
+        {
+            return IsRuYear(iYear) ? 366 : 365;
+        }
+
+        /// <summary>本年有多少天</summary>
+        /// <param name="dt">日期</param>
+        /// <returns>本天在当年的天数</returns>
+        public static int GetDaysOfYear(this in DateTime dt)
+        {
+            //取得传入参数的年份部分,用来判断是否是闰年
+            int n = dt.Year;
+            return IsRuYear(n) ? 366 : 365;
+        }
+
+        /// <summary>本月有多少天</summary>
+        /// <param name="_"></param>
+        /// <param name="iYear">年</param>
+        /// <param name="month">月</param>
+        /// <returns>天数</returns>
+        public static int GetDaysOfMonth(this DateTime _, int iYear, int month)
+        {
+            return month switch
+            {
+                1 => 31,
+                2 => (IsRuYear(iYear) ? 29 : 28),
+                3 => 31,
+                4 => 30,
+                5 => 31,
+                6 => 30,
+                7 => 31,
+                8 => 31,
+                9 => 30,
+                10 => 31,
+                11 => 30,
+                12 => 31,
+                _ => 0
+            };
+        }
+
+        /// <summary>本月有多少天</summary>
+        /// <param name="dt">日期</param>
+        /// <returns>天数</returns>
+        public static int GetDaysOfMonth(this in DateTime dt)
+        {
+            //--利用年月信息,得到当前月的天数信息。
+            return dt.Month switch
+            {
+                1 => 31,
+                2 => (IsRuYear(dt.Year) ? 29 : 28),
+                3 => 31,
+                4 => 30,
+                5 => 31,
+                6 => 30,
+                7 => 31,
+                8 => 31,
+                9 => 30,
+                10 => 31,
+                11 => 30,
+                12 => 31,
+                _ => 0
+            };
+        }
+
+        /// <summary>返回当前日期的星期名称</summary>
+        /// <param name="idt">日期</param>
+        /// <returns>星期名称</returns>
+        public static string GetWeekNameOfDay(this in DateTime idt)
+        {
+            return idt.DayOfWeek.ToString() switch
+            {
+                "Mondy" => "星期一",
+                "Tuesday" => "星期二",
+                "Wednesday" => "星期三",
+                "Thursday" => "星期四",
+                "Friday" => "星期五",
+                "Saturday" => "星期六",
+                "Sunday" => "星期日",
+                _ => ""
+            };
+        }
+
+        /// <summary>返回当前日期的星期编号</summary>
+        /// <param name="idt">日期</param>
+        /// <returns>星期数字编号</returns>
+        public static string GetWeekNumberOfDay(this in DateTime idt)
+        {
+            return idt.DayOfWeek.ToString() switch
+            {
+                "Mondy" => "1",
+                "Tuesday" => "2",
+                "Wednesday" => "3",
+                "Thursday" => "4",
+                "Friday" => "5",
+                "Saturday" => "6",
+                "Sunday" => "7",
+                _ => ""
+            };
+        }
+
+        /// <summary>判断当前年份是否是闰年,私有函数</summary>
+        /// <param name="iYear">年份</param>
+        /// <returns>是闰年:True ,不是闰年:False</returns>
+        private static bool IsRuYear(int iYear)
+        {
+            //形式参数为年份
+            //例如:2003
+            var n = iYear;
+            return n % 400 == 0 || n % 4 == 0 && n % 100 != 0;
+        }
+
+        /// <summary>
+        /// 判断是否为合法日期,必须大于1800年1月1日
+        /// </summary>
+        /// <param name="strDate">输入日期字符串</param>
+        /// <returns>True/False</returns>
+        public static bool IsDateTime(this string strDate)
+        {
+            DateTime.TryParse(strDate, out var result);
+            return result.CompareTo(DateTime.Parse("1800-1-1")) > 0;
+        }
+
+        /// <summary>
+        /// 判断时间是否在区间内
+        /// </summary>
+        /// <param name="this"></param>
+        /// <param name="start">开始</param>
+        /// <param name="end">结束</param>
+        /// <param name="mode">模式</param>
+        /// <returns></returns>
+        public static bool In(this in DateTime @this, DateTime start, DateTime end, RangeMode mode = RangeMode.Close)
+        {
+            return mode switch
+            {
+                RangeMode.Open => start < @this && end > @this,
+                RangeMode.Close => start <= @this && end >= @this,
+                RangeMode.OpenClose => start < @this && end >= @this,
+                RangeMode.CloseOpen => start <= @this && end > @this,
+                _ => throw new ArgumentOutOfRangeException(nameof(mode), mode, null)
+            };
+        }
+
+        /// <summary>
+        ///  返回每月的第一天和最后一天
+        /// </summary>
+        /// <param name="_"></param>
+        /// <param name="month">月份</param>
+        /// <param name="firstDay">第一天</param>
+        /// <param name="lastDay">最后一天</param>
+        public static void ReturnDateFormat(this DateTime _, int month, out string firstDay, out string lastDay)
+        {
+            int year = DateTime.Now.Year + month / 12;
+            if (month != 12)
+            {
+                month %= 12;
+            }
+
+            switch (month)
+            {
+                case 1:
+                    firstDay = DateTime.Now.ToString($"{year}-0{month}-01");
+                    lastDay = DateTime.Now.ToString($"{year}-0{month}-31");
+                    break;
+                case 2:
+                    firstDay = DateTime.Now.ToString(year + "-0" + month + "-01");
+                    lastDay = DateTime.IsLeapYear(DateTime.Now.Year) ? DateTime.Now.ToString(year + "-0" + month + "-29") : DateTime.Now.ToString(year + "-0" + month + "-28");
+                    break;
+                case 3:
+                    firstDay = DateTime.Now.ToString(year + "-0" + month + "-01");
+                    lastDay = DateTime.Now.ToString("yyyy-0" + month + "-31");
+                    break;
+                case 4:
+                    firstDay = DateTime.Now.ToString(year + "-0" + month + "-01");
+                    lastDay = DateTime.Now.ToString(year + "-0" + month + "-30");
+                    break;
+                case 5:
+                    firstDay = DateTime.Now.ToString(year + "-0" + month + "-01");
+                    lastDay = DateTime.Now.ToString(year + "-0" + month + "-31");
+                    break;
+                case 6:
+                    firstDay = DateTime.Now.ToString(year + "-0" + month + "-01");
+                    lastDay = DateTime.Now.ToString(year + "-0" + month + "-30");
+                    break;
+                case 7:
+                    firstDay = DateTime.Now.ToString(year + "-0" + month + "-01");
+                    lastDay = DateTime.Now.ToString(year + "-0" + month + "-31");
+                    break;
+                case 8:
+                    firstDay = DateTime.Now.ToString(year + "-0" + month + "-01");
+                    lastDay = DateTime.Now.ToString(year + "-0" + month + "-31");
+                    break;
+                case 9:
+                    firstDay = DateTime.Now.ToString(year + "-0" + month + "-01");
+                    lastDay = DateTime.Now.ToString(year + "-0" + month + "-30");
+                    break;
+                case 10:
+                    firstDay = DateTime.Now.ToString(year + "-" + month + "-01");
+                    lastDay = DateTime.Now.ToString(year + "-" + month + "-31");
+                    break;
+                case 11:
+                    firstDay = DateTime.Now.ToString(year + "-" + month + "-01");
+                    lastDay = DateTime.Now.ToString(year + "-" + month + "-30");
+                    break;
+                default:
+                    firstDay = DateTime.Now.ToString(year + "-" + month + "-01");
+                    lastDay = DateTime.Now.ToString(year + "-" + month + "-31");
+                    break;
+            }
+        }
+
+        /// <summary>
+        /// 返回某年某月最后一天
+        /// </summary>
+        /// <param name="_"></param>
+        /// <param name="year">年份</param>
+        /// <param name="month">月份</param>
+        /// <returns>日</returns>
+        public static int GetMonthLastDate(this DateTime _, int year, int month)
+        {
+            DateTime lastDay = new DateTime(year, month, new GregorianCalendar().GetDaysInMonth(year, month));
+            int day = lastDay.Day;
+            return day;
+        }
+
+        /// <summary>
+        /// 获得一段时间内有多少小时
+        /// </summary>
+        /// <param name="dtStar">起始时间</param>
+        /// <param name="dtEnd">终止时间</param>
+        /// <returns>小时差</returns>
+        public static string GetTimeDelay(this in DateTime dtStar, DateTime dtEnd)
+        {
+            long lTicks = (dtEnd.Ticks - dtStar.Ticks) / 10000000;
+            string sTemp = (lTicks / 3600).ToString().PadLeft(2, '0') + ":";
+            sTemp += (lTicks % 3600 / 60).ToString().PadLeft(2, '0') + ":";
+            sTemp += (lTicks % 3600 % 60).ToString().PadLeft(2, '0');
+            return sTemp;
+        }
+
+        /// <summary>
+        /// 获得8位时间整型数字
+        /// </summary>
+        /// <param name="dt">当前的日期时间对象</param>
+        /// <returns>8位时间整型数字</returns>
+        public static string GetDateString(this in DateTime dt)
+        {
+            return dt.Year + dt.Month.ToString().PadLeft(2, '0') + dt.Day.ToString().PadLeft(2, '0');
+        }
+
+        /// <summary>
+        /// 返回时间差
+        /// </summary>
+        /// <param name="dateTime1">时间1</param>
+        /// <param name="dateTime2">时间2</param>
+        /// <returns>时间差</returns>
+        public static string DateDiff(this in DateTime dateTime1, in DateTime dateTime2)
+        {
+            string dateDiff;
+            var ts = dateTime2 - dateTime1;
+            if (ts.Days >= 1)
+            {
+                dateDiff = dateTime1.Month + "月" + dateTime1.Day + "日";
+            }
+            else
+            {
+                dateDiff = ts.Hours > 1 ? ts.Hours + "小时前" : ts.Minutes + "分钟前";
+            }
+
+            return dateDiff;
+        }
+
+        /// <summary>
+        /// 计算2个时间差
+        /// </summary>
+        /// <param name="beginTime">开始时间</param>
+        /// <param name="endTime">结束时间</param>
+        /// <returns>时间差</returns>
+        public static string GetDiffTime(this in DateTime beginTime, in DateTime endTime)
+        {
+            string strResout = string.Empty;
+            //获得2时间的时间间隔秒计算
+            TimeSpan span = endTime.Subtract(beginTime);
+            int sec = Convert.ToInt32(span.TotalSeconds);
+            int minutes = 1 * 60;
+            int hours = minutes * 60;
+            int day = hours * 24;
+            int month = day * 30;
+            int year = month * 12;
+
+            //提醒时间,到了返回1,否则返回0
+            if (sec > year)
+            {
+                strResout += sec / year + "年";
+                sec %= year; //剩余
+            }
+
+            if (sec > month)
+            {
+                strResout += sec / month + "月";
+                sec %= month;
+            }
+
+            if (sec > day)
+            {
+                strResout += sec / day + "天";
+                sec %= day;
+            }
+
+            if (sec > hours)
+            {
+                strResout += sec / hours + "小时";
+                sec %= hours;
+            }
+
+            if (sec > minutes)
+            {
+                strResout += sec / minutes + "分";
+                sec %= minutes;
+            }
+
+            strResout += sec + "秒";
+            return strResout;
+        }
+    }
+
+    /// <summary>
+    /// 区间模式
+    /// </summary>
+    public enum RangeMode
+    {
+        /// <summary>
+        /// 开区间
+        /// </summary>
+        Open,
+
+        /// <summary>
+        /// 闭区间
+        /// </summary>
+        Close,
+
+        /// <summary>
+        /// 左开右闭区间
+        /// </summary>
+        OpenClose,
+
+        /// <summary>
+        /// 左闭右开区间
+        /// </summary>
+        CloseOpen
     }
-}
+}

+ 0 - 274
Masuit.Tools.Abstractions/DateTimeExt/DateUtil.cs

@@ -1,274 +0,0 @@
-using System;
-using System.Diagnostics;
-
-namespace Masuit.Tools.DateTimeExt
-{
-    /// <summary>
-    /// 日期操作工具类
-    /// </summary>
-    public static class DateUtil
-    {
-        /// <summary>
-        /// 返回相对于当前时间的相对天数
-        /// </summary>
-        /// <param name="dt"></param>
-        /// <param name="relativeday">相对天数</param>
-        public static string GetDateTime(this DateTime dt, int relativeday)
-        {
-            return dt.AddDays(relativeday).ToString("yyyy-MM-dd HH:mm:ss");
-        }
-
-        /// <summary>
-        /// 返回标准时间格式string
-        /// </summary>
-        public static string GetDateTimeF(this DateTime dt) => dt.ToString("yyyy-MM-dd HH:mm:ss:fffffff");
-
-        /// <summary>
-        /// 返回标准时间 
-        /// </summary>
-        /// <param name="fDateTime">日期时间字符串</param>
-        /// <param name="formatStr">格式</param>
-        public static string GetStandardDateTime(this string fDateTime, string formatStr)
-        {
-            if (fDateTime == "0000-0-0 0:00:00")
-            {
-                return fDateTime;
-            }
-
-            var s = Convert.ToDateTime(fDateTime);
-            return s.ToString(formatStr);
-        }
-
-        /// <summary>
-        /// 返回标准时间 yyyy-MM-dd HH:mm:ss
-        /// </summary>
-        /// <param name="fDateTime">日期时间字符串</param>
-        public static string GetStandardDateTime(this string fDateTime)
-        {
-            return GetStandardDateTime(fDateTime, "yyyy-MM-dd HH:mm:ss");
-        }
-
-        /// <summary>
-        /// 获取该时间相对于1970-01-01 00:00:00的秒数
-        /// </summary>
-        /// <param name="dt"></param>
-        /// <returns></returns>
-        public static double GetTotalSeconds(this DateTime dt) => new DateTimeOffset(dt).ToUnixTimeSeconds();
-
-        /// <summary>
-        /// 获取该时间相对于1970-01-01 00:00:00的毫秒数
-        /// </summary>
-        /// <param name="dt"></param>
-        /// <returns></returns>
-        public static double GetTotalMilliseconds(this DateTime dt) => new DateTimeOffset(dt).ToUnixTimeMilliseconds();
-
-        /// <summary>
-        /// 获取该时间相对于1970-01-01 00:00:00的微秒时间戳
-        /// </summary>
-        /// <param name="dt"></param>
-        /// <returns></returns>
-        public static long GetTotalMicroseconds(this DateTime dt) => new DateTimeOffset(dt).Ticks / 10;
-
-        /// <summary>
-        /// 获取该时间相对于1970-01-01 00:00:00的纳秒时间戳
-        /// </summary>
-        /// <param name="dt"></param>
-        /// <returns></returns>
-        public static long GetTotalNanoseconds(this DateTime dt) => new DateTimeOffset(dt).Ticks * 100 + Stopwatch.GetTimestamp() % 100;
-
-        /// <summary>
-        /// 获取该时间相对于1970-01-01 00:00:00的分钟数
-        /// </summary>
-        /// <param name="dt"></param>
-        /// <returns></returns>
-        public static double GetTotalMinutes(this DateTime dt) => new DateTimeOffset(dt).Offset.TotalMinutes;
-
-        /// <summary>
-        /// 获取该时间相对于1970-01-01 00:00:00的小时数
-        /// </summary>
-        /// <param name="dt"></param>
-        /// <returns></returns>
-        public static double GetTotalHours(this DateTime dt) => new DateTimeOffset(dt).Offset.TotalHours;
-
-        /// <summary>
-        /// 获取该时间相对于1970-01-01 00:00:00的天数
-        /// </summary>
-        /// <param name="dt"></param>
-        /// <returns></returns>
-        public static double GetTotalDays(this DateTime dt) => new DateTimeOffset(dt).Offset.TotalDays;
-
-        /// <summary>
-        /// 返回本年有多少天
-        /// </summary>
-        /// <param name="_"></param>
-        /// <param name="iYear">年份</param>
-        /// <returns>本年的天数</returns>
-        public static int GetDaysOfYear(this DateTime _, int iYear)
-        {
-            return IsRuYear(iYear) ? 366 : 365;
-        }
-
-        /// <summary>本年有多少天</summary>
-        /// <param name="dt">日期</param>
-        /// <returns>本天在当年的天数</returns>
-        public static int GetDaysOfYear(this DateTime dt)
-        {
-            //取得传入参数的年份部分,用来判断是否是闰年
-            int n = dt.Year;
-            return IsRuYear(n) ? 366 : 365;
-        }
-
-        /// <summary>本月有多少天</summary>
-        /// <param name="_"></param>
-        /// <param name="iYear">年</param>
-        /// <param name="month">月</param>
-        /// <returns>天数</returns>
-        public static int GetDaysOfMonth(this DateTime _, int iYear, int month)
-        {
-            return month switch
-            {
-                1 => 31,
-                2 => (IsRuYear(iYear) ? 29 : 28),
-                3 => 31,
-                4 => 30,
-                5 => 31,
-                6 => 30,
-                7 => 31,
-                8 => 31,
-                9 => 30,
-                10 => 31,
-                11 => 30,
-                12 => 31,
-                _ => 0
-            };
-        }
-
-        /// <summary>本月有多少天</summary>
-        /// <param name="dt">日期</param>
-        /// <returns>天数</returns>
-        public static int GetDaysOfMonth(this DateTime dt)
-        {
-            //--利用年月信息,得到当前月的天数信息。
-            return dt.Month switch
-            {
-                1 => 31,
-                2 => (IsRuYear(dt.Year) ? 29 : 28),
-                3 => 31,
-                4 => 30,
-                5 => 31,
-                6 => 30,
-                7 => 31,
-                8 => 31,
-                9 => 30,
-                10 => 31,
-                11 => 30,
-                12 => 31,
-                _ => 0
-            };
-        }
-
-        /// <summary>返回当前日期的星期名称</summary>
-        /// <param name="idt">日期</param>
-        /// <returns>星期名称</returns>
-        public static string GetWeekNameOfDay(this DateTime idt)
-        {
-            return idt.DayOfWeek.ToString() switch
-            {
-                "Mondy" => "星期一",
-                "Tuesday" => "星期二",
-                "Wednesday" => "星期三",
-                "Thursday" => "星期四",
-                "Friday" => "星期五",
-                "Saturday" => "星期六",
-                "Sunday" => "星期日",
-                _ => ""
-            };
-        }
-
-        /// <summary>返回当前日期的星期编号</summary>
-        /// <param name="idt">日期</param>
-        /// <returns>星期数字编号</returns>
-        public static string GetWeekNumberOfDay(this DateTime idt)
-        {
-            return idt.DayOfWeek.ToString() switch
-            {
-                "Mondy" => "1",
-                "Tuesday" => "2",
-                "Wednesday" => "3",
-                "Thursday" => "4",
-                "Friday" => "5",
-                "Saturday" => "6",
-                "Sunday" => "7",
-                _ => ""
-            };
-        }
-
-        /// <summary>判断当前年份是否是闰年,私有函数</summary>
-        /// <param name="iYear">年份</param>
-        /// <returns>是闰年:True ,不是闰年:False</returns>
-        private static bool IsRuYear(int iYear)
-        {
-            //形式参数为年份
-            //例如:2003
-            var n = iYear;
-            return n % 400 == 0 || n % 4 == 0 && n % 100 != 0;
-        }
-
-        /// <summary>
-        /// 判断是否为合法日期,必须大于1800年1月1日
-        /// </summary>
-        /// <param name="strDate">输入日期字符串</param>
-        /// <returns>True/False</returns>
-        public static bool IsDateTime(this string strDate)
-        {
-            DateTime.TryParse(strDate, out var result);
-            return result.CompareTo(DateTime.Parse("1800-1-1")) > 0;
-        }
-
-        /// <summary>
-        /// 判断时间是否在区间内
-        /// </summary>
-        /// <param name="this"></param>
-        /// <param name="start">开始</param>
-        /// <param name="end">结束</param>
-        /// <param name="mode">模式</param>
-        /// <returns></returns>
-        public static bool In(this DateTime @this, DateTime start, DateTime end, RangeMode mode = RangeMode.Close)
-        {
-            return mode switch
-            {
-                RangeMode.Open => start < @this && end > @this,
-                RangeMode.Close => start <= @this && end >= @this,
-                RangeMode.OpenClose => start < @this && end >= @this,
-                RangeMode.CloseOpen => start <= @this && end > @this,
-                _ => throw new ArgumentOutOfRangeException(nameof(mode), mode, null)
-            };
-        }
-    }
-
-    /// <summary>
-    /// 区间模式
-    /// </summary>
-    public enum RangeMode
-    {
-        /// <summary>
-        /// 开区间
-        /// </summary>
-        Open,
-
-        /// <summary>
-        /// 闭区间
-        /// </summary>
-        Close,
-
-        /// <summary>
-        /// 左开右闭区间
-        /// </summary>
-        OpenClose,
-
-        /// <summary>
-        /// 左闭右开区间
-        /// </summary>
-        CloseOpen
-    }
-}

+ 0 - 404
Masuit.Tools.Abstractions/DateTimeExt/TimeHelper.cs

@@ -1,404 +0,0 @@
-using System;
-using System.Globalization;
-
-namespace Masuit.Tools.DateTimeExt
-{
-    /// <summary>
-    /// 时间相关操作帮助类
-    /// </summary>
-    public static class TimeHelper
-    {
-        #region 返回每月的第一天和最后一天
-
-        /// <summary>
-        ///  返回每月的第一天和最后一天
-        /// </summary>
-        /// <param name="_"></param>
-        /// <param name="month">月份</param>
-        /// <param name="firstDay">第一天</param>
-        /// <param name="lastDay">最后一天</param>
-        public static void ReturnDateFormat(this DateTime _, int month, out string firstDay, out string lastDay)
-        {
-            int year = DateTime.Now.Year + month / 12;
-            if (month != 12)
-            {
-                month %= 12;
-            }
-
-            switch (month)
-            {
-                case 1:
-                    firstDay = DateTime.Now.ToString($"{year}-0{month}-01");
-                    lastDay = DateTime.Now.ToString($"{year}-0{month}-31");
-                    break;
-                case 2:
-                    firstDay = DateTime.Now.ToString(year + "-0" + month + "-01");
-                    lastDay = DateTime.IsLeapYear(DateTime.Now.Year) ? DateTime.Now.ToString(year + "-0" + month + "-29") : DateTime.Now.ToString(year + "-0" + month + "-28");
-                    break;
-                case 3:
-                    firstDay = DateTime.Now.ToString(year + "-0" + month + "-01");
-                    lastDay = DateTime.Now.ToString("yyyy-0" + month + "-31");
-                    break;
-                case 4:
-                    firstDay = DateTime.Now.ToString(year + "-0" + month + "-01");
-                    lastDay = DateTime.Now.ToString(year + "-0" + month + "-30");
-                    break;
-                case 5:
-                    firstDay = DateTime.Now.ToString(year + "-0" + month + "-01");
-                    lastDay = DateTime.Now.ToString(year + "-0" + month + "-31");
-                    break;
-                case 6:
-                    firstDay = DateTime.Now.ToString(year + "-0" + month + "-01");
-                    lastDay = DateTime.Now.ToString(year + "-0" + month + "-30");
-                    break;
-                case 7:
-                    firstDay = DateTime.Now.ToString(year + "-0" + month + "-01");
-                    lastDay = DateTime.Now.ToString(year + "-0" + month + "-31");
-                    break;
-                case 8:
-                    firstDay = DateTime.Now.ToString(year + "-0" + month + "-01");
-                    lastDay = DateTime.Now.ToString(year + "-0" + month + "-31");
-                    break;
-                case 9:
-                    firstDay = DateTime.Now.ToString(year + "-0" + month + "-01");
-                    lastDay = DateTime.Now.ToString(year + "-0" + month + "-30");
-                    break;
-                case 10:
-                    firstDay = DateTime.Now.ToString(year + "-" + month + "-01");
-                    lastDay = DateTime.Now.ToString(year + "-" + month + "-31");
-                    break;
-                case 11:
-                    firstDay = DateTime.Now.ToString(year + "-" + month + "-01");
-                    lastDay = DateTime.Now.ToString(year + "-" + month + "-30");
-                    break;
-                default:
-                    firstDay = DateTime.Now.ToString(year + "-" + month + "-01");
-                    lastDay = DateTime.Now.ToString(year + "-" + month + "-31");
-                    break;
-            }
-        }
-
-        #endregion
-
-        #region  将时间格式化成 年月日 的形式,如果时间为null,返回当前系统时间
-
-        /// <summary>
-        /// 将时间格式化成 年月日 的形式,如果时间为null,返回当前系统时间
-        /// </summary>
-        /// <param name="dt">年月日分隔符</param>
-        /// <param name="separator">分隔符</param>
-        /// <returns>xxxx年xx月xx日</returns>
-        public static string GetFormatDate(this DateTime dt, char separator)
-        {
-            if (dt.Equals(DBNull.Value))
-            {
-                return GetFormatDate(DateTime.Now, separator);
-            }
-
-            string tem = $"yyyy{separator}MM{separator}dd";
-            return dt.ToString(tem);
-
-        }
-
-        #endregion
-
-        #region 将时间格式化成 时分秒 的形式,如果时间为null,返回当前系统时间
-
-        /// <summary>
-        /// 将时间格式化成 时分秒 的形式,如果时间为null,返回当前系统时间
-        /// </summary>
-        /// <param name="dt">当前日期时间对象</param>
-        /// <param name="separator">分隔符</param>
-        /// <returns> xx时xx分xx秒 </returns>
-        public static string GetFormatTime(this DateTime dt, char separator)
-        {
-            if (dt.Equals(DBNull.Value))
-            {
-                return GetFormatDate(DateTime.Now, separator);
-            }
-
-            string tem = $"hh{separator}mm{separator}ss";
-            return dt.ToString(tem);
-
-        }
-
-        #endregion
-
-        #region  把秒转换成分钟
-
-        /// <summary>
-        /// 把秒转换成分钟
-        /// </summary>
-        /// <param name="_"></param>
-        /// <param name="second">秒数</param>
-        /// <returns>分钟数</returns>
-        public static int SecondToMinute(this DateTime _, int second)
-        {
-            decimal mm = second / (decimal)60;
-            return Convert.ToInt32(Math.Ceiling(mm));
-        }
-
-        #endregion
-
-        #region 返回某年某月最后一天
-
-        /// <summary>
-        /// 返回某年某月最后一天
-        /// </summary>
-        /// <param name="_"></param>
-        /// <param name="year">年份</param>
-        /// <param name="month">月份</param>
-        /// <returns>日</returns>
-        public static int GetMonthLastDate(this DateTime _, int year, int month)
-        {
-            DateTime lastDay = new DateTime(year, month, new GregorianCalendar().GetDaysInMonth(year, month));
-            int day = lastDay.Day;
-            return day;
-        }
-
-        #endregion
-
-        #region 获得两个日期的间隔
-
-        /// <summary>
-        /// 获得两个日期的间隔
-        /// </summary>
-        /// <param name="dateTime1">日期一。</param>
-        /// <param name="dateTime2">日期二。</param>
-        /// <returns>日期间隔TimeSpan。</returns>
-        /// <exception cref="OverflowException">The return value is less than <see cref="F:System.TimeSpan.MinValue" /> or greater than <see cref="F:System.TimeSpan.MaxValue" />. </exception>
-        public static TimeSpan DateDiff2(this DateTime dateTime1, DateTime dateTime2)
-        {
-            return dateTime1 - dateTime2;
-        }
-
-        #endregion
-
-        #region 得到随机日期
-
-        /// <summary>
-        /// 得到随机日期
-        /// </summary>
-        /// <param name="time1">起始日期</param>
-        /// <param name="time2">结束日期</param>
-        /// <returns>间隔日期之间的 随机日期</returns>
-        public static DateTime GetRandomTime(this DateTime time1, DateTime time2)
-        {
-            var random = new Random();
-            DateTime minTime;
-            var ts = new TimeSpan(time1.Ticks - time2.Ticks);
-            // 获取两个时间相隔的秒数
-            double dTotalSecontds = ts.TotalSeconds;
-            int iTotalSecontds;
-            if (dTotalSecontds > int.MaxValue) iTotalSecontds = int.MaxValue;
-            else if (dTotalSecontds < int.MinValue) iTotalSecontds = int.MinValue;
-            else iTotalSecontds = (int)dTotalSecontds;
-            if (iTotalSecontds > 0)
-            {
-                minTime = time2;
-            }
-            else if (iTotalSecontds < 0)
-            {
-                minTime = time1;
-            }
-            else
-            {
-                return time1;
-            }
-
-            int maxValue = iTotalSecontds;
-            if (iTotalSecontds <= int.MinValue)
-            {
-                maxValue = int.MinValue + 1;
-            }
-
-            int i = random.Next(Math.Abs(maxValue));
-            return minTime.AddSeconds(i);
-        }
-
-        #endregion
-
-        #region Rss日期时间转换,将时间全部转换为GMT时间
-
-        /// <summary> 
-        /// Rss日期时间转换,将时间全部转换为GMT时间 
-        /// </summary> 
-        /// <param name="strDateTime">Rss中读取的时间</param> 
-        /// <returns>处理后的标准时间格式</returns> 
-        public static string DateConvert(this string strDateTime)
-        {
-            strDateTime = strDateTime.Replace("+0000", "GMT");
-            strDateTime = strDateTime.Replace("+0100", "GMT");
-            strDateTime = strDateTime.Replace("+0200", "GMT");
-            strDateTime = strDateTime.Replace("+0300", "GMT");
-            strDateTime = strDateTime.Replace("+0400", "GMT");
-            strDateTime = strDateTime.Replace("+0500", "GMT");
-            strDateTime = strDateTime.Replace("+0600", "GMT");
-            strDateTime = strDateTime.Replace("+0700", "GMT");
-            strDateTime = strDateTime.Replace("+0800", "GMT");
-            strDateTime = strDateTime.Replace("-0000", "GMT");
-            strDateTime = strDateTime.Replace("-0100", "GMT");
-            strDateTime = strDateTime.Replace("-0200", "GMT");
-            strDateTime = strDateTime.Replace("-0300", "GMT");
-            strDateTime = strDateTime.Replace("-0400", "GMT");
-            strDateTime = strDateTime.Replace("-0500", "GMT");
-            strDateTime = strDateTime.Replace("-0600", "GMT");
-            strDateTime = strDateTime.Replace("-0700", "GMT");
-            strDateTime = strDateTime.Replace("-0800", "GMT");
-            DateTime dt = DateTime.Parse(strDateTime, null, DateTimeStyles.AdjustToUniversal);
-            return dt.ToString();
-        }
-
-        #endregion
-
-        #region 时间相关操作类
-
-        /// <summary>
-        /// 获得一段时间内有多少小时
-        /// </summary>
-        /// <param name="dtStar">起始时间</param>
-        /// <param name="dtEnd">终止时间</param>
-        /// <returns>小时差</returns>
-        public static string GetTimeDelay(this DateTime dtStar, DateTime dtEnd)
-        {
-            long lTicks = (dtEnd.Ticks - dtStar.Ticks) / 10000000;
-            string sTemp = (lTicks / 3600).ToString().PadLeft(2, '0') + ":";
-            sTemp += (lTicks % 3600 / 60).ToString().PadLeft(2, '0') + ":";
-            sTemp += (lTicks % 3600 % 60).ToString().PadLeft(2, '0');
-            return sTemp;
-        }
-
-        /// <summary>
-        /// 获得8位时间整型数字
-        /// </summary>
-        /// <param name="dt">当前的日期时间对象</param>
-        /// <returns>8位时间整型数字</returns>
-        public static string GetDateString(this DateTime dt)
-        {
-            return dt.Year + dt.Month.ToString().PadLeft(2, '0') + dt.Day.ToString().PadLeft(2, '0');
-        }
-
-        #endregion
-
-        #region 返回时间差
-
-        /// <summary>
-        /// 返回时间差
-        /// </summary>
-        /// <param name="dateTime1">时间1</param>
-        /// <param name="dateTime2">时间2</param>
-        /// <returns>时间差</returns>
-        public static string DateDiff(this DateTime dateTime1, DateTime dateTime2)
-        {
-            string dateDiff;
-            var ts = dateTime2 - dateTime1;
-            if (ts.Days >= 1)
-            {
-                dateDiff = dateTime1.Month + "月" + dateTime1.Day + "日";
-            }
-            else
-            {
-                dateDiff = ts.Hours > 1 ? ts.Hours + "小时前" : ts.Minutes + "分钟前";
-            }
-
-            return dateDiff;
-        }
-
-        /// <summary>
-        /// 计算2个时间差
-        /// </summary>
-        /// <param name="beginTime">开始时间</param>
-        /// <param name="endTime">结束时间</param>
-        /// <returns>时间差</returns>
-        public static string GetDiffTime(this DateTime beginTime, DateTime endTime)
-        {
-            string strResout = string.Empty;
-            //获得2时间的时间间隔秒计算
-            TimeSpan span = endTime.Subtract(beginTime);
-            int sec = Convert.ToInt32(span.TotalSeconds);
-            int minutes = 1 * 60;
-            int hours = minutes * 60;
-            int day = hours * 24;
-            int month = day * 30;
-            int year = month * 12;
-
-            //提醒时间,到了返回1,否则返回0
-            if (sec > year)
-            {
-                strResout += sec / year + "年";
-                sec %= year; //剩余
-            }
-
-            if (sec > month)
-            {
-                strResout += sec / month + "月";
-                sec %= month;
-            }
-
-            if (sec > day)
-            {
-                strResout += sec / day + "天";
-                sec %= day;
-            }
-
-            if (sec > hours)
-            {
-                strResout += sec / hours + "小时";
-                sec %= hours;
-            }
-
-            if (sec > minutes)
-            {
-                strResout += sec / minutes + "分";
-                sec %= minutes;
-            }
-
-            strResout += sec + "秒";
-            return strResout;
-        }
-
-        #endregion
-
-        #region 时间其他转换静态方法
-
-        /// <summary>
-        /// C#的时间到Javascript的时间的转换
-        /// </summary>
-        /// <param name="theDate">C#的时间</param>
-        /// <returns>Javascript的时间</returns>
-        public static long CsharpTime2JavascriptTime(this DateTime theDate)
-        {
-            DateTime d1 = new DateTime(1970, 1, 1);
-            DateTime d2 = theDate.ToUniversalTime();
-            TimeSpan ts = new TimeSpan(d2.Ticks - d1.Ticks);
-            return (long)ts.TotalMilliseconds;
-        }
-
-        /// <summary>
-        /// PHP的时间转换成C#中的DateTime
-        /// </summary>
-        /// <param name="_"></param>
-        /// <param name="time">php的时间</param>
-        /// <returns>C#的时间</returns>
-        public static DateTime PhpTime2CsharpTime(this DateTime _, long time)
-        {
-            DateTime timeStamp = new DateTime(1970, 1, 1); //得到1970年的时间戳
-            long t = (time + 8 * 60 * 60) * 10000000 + timeStamp.Ticks;
-            return new DateTime(t);
-        }
-
-        /// <summary>
-        ///  C#中的DateTime转换成PHP的时间
-        /// </summary>
-        /// <param name="time">C#时间</param>
-        /// <returns>php时间</returns>
-        public static long CsharpTime2PhpTime(this DateTime time)
-        {
-            DateTime timeStamp = new DateTime(1970, 1, 1); //得到1970年的时间戳
-            //注意这里有时区问题,用now就要减掉8个小时
-            return (DateTime.UtcNow.Ticks - timeStamp.Ticks) / 10000000;
-        }
-
-        #endregion
-    }
-}

+ 0 - 92
Masuit.Tools.Abstractions/Files/WinrarHelper.cs

@@ -1,92 +0,0 @@
-using Microsoft.Win32;
-using System.Diagnostics;
-
-namespace Masuit.Tools.Files
-{
-    /// <summary>
-    /// WinRAR压缩操作
-    /// </summary>
-    public static class WinrarHelper
-    {
-        #region 压缩
-
-        /// <summary>
-        /// 压缩
-        /// </summary>
-        /// <param name="zipname">要解压的文件名</param>
-        /// <param name="zippath">要压缩的文件目录</param>
-        /// <param name="dirpath">初始目录</param>
-        public static void Rar(string zipname, string zippath, string dirpath)
-        {
-            _theReg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRAR.exe\Shell\Open\Command");
-            if (_theReg != null)
-            {
-                _theObj = _theReg.GetValue("");
-                _theRar = _theObj.ToString();
-                _theReg?.Close();
-            }
-
-            _theRar = _theRar.Substring(1, _theRar.Length - 7);
-            _theInfo = " a  " + zipname + " " + zippath;
-            _theStartInfo = new ProcessStartInfo
-            {
-                FileName = _theRar,
-                Arguments = _theInfo,
-                WindowStyle = ProcessWindowStyle.Hidden,
-                WorkingDirectory = dirpath
-            };
-            _theProcess = new Process
-            {
-                StartInfo = _theStartInfo
-            };
-            _theProcess.Start();
-        }
-
-        #endregion
-
-        #region 解压缩
-
-        /// <summary>
-        /// 解压缩
-        /// </summary>
-        /// <param name="zipname">要解压的文件名</param>
-        /// <param name="zippath">要解压的文件路径</param>
-        public static void UnRar(string zipname, string zippath)
-        {
-            _theReg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRar.exe\Shell\Open\Command");
-            if (_theReg != null)
-            {
-                _theObj = _theReg.GetValue("");
-                _theRar = _theObj.ToString();
-                _theReg.Close();
-            }
-
-            _theRar = _theRar.Substring(1, _theRar.Length - 7);
-            _theInfo = " X " + zipname + " " + zippath;
-            _theStartInfo = new ProcessStartInfo
-            {
-                FileName = _theRar,
-                Arguments = _theInfo,
-                WindowStyle = ProcessWindowStyle.Hidden
-            };
-            _theProcess = new Process
-            {
-                StartInfo = _theStartInfo
-            };
-            _theProcess.Start();
-        }
-
-        #endregion
-
-        #region 私有变量
-
-        private static string _theRar;
-        private static RegistryKey _theReg;
-        private static object _theObj;
-        private static string _theInfo;
-        private static ProcessStartInfo _theStartInfo;
-        private static Process _theProcess;
-
-        #endregion
-    }
-}

+ 0 - 12
Masuit.Tools.Core/Masuit.Tools.Core.csproj

@@ -30,9 +30,6 @@
 
   <ItemGroup>
     <Compile Include="..\Masuit.Tools.Abstractions\Config\CoreConfig.cs" Link="Config\CoreConfig.cs" />
-    <Compile Include="..\Masuit.Tools.Abstractions\Database\DataExt.cs">
-      <Link>Database\DataExt.cs</Link>
-    </Compile>
     <Compile Include="..\Masuit.Tools.Abstractions\Database\DataTableBuilder.cs">
       <Link>Database\DataTableBuilder.cs</Link>
     </Compile>
@@ -48,12 +45,6 @@
     <Compile Include="..\Masuit.Tools.Abstractions\DateTimeExt\DateTimeHelper.cs">
       <Link>DateTimeExt\DateTimeHelper.cs</Link>
     </Compile>
-    <Compile Include="..\Masuit.Tools.Abstractions\DateTimeExt\DateUtil.cs">
-      <Link>DateTimeExt\DateUtil.cs</Link>
-    </Compile>
-    <Compile Include="..\Masuit.Tools.Abstractions\DateTimeExt\TimeHelper.cs">
-      <Link>DateTimeExt\TimeHelper.cs</Link>
-    </Compile>
     <Compile Include="..\Masuit.Tools.Abstractions\DateTimeExt\WeekHolidayStruct.cs">
       <Link>DateTimeExt\WeekHolidayStruct.cs</Link>
     </Compile>
@@ -105,9 +96,6 @@
     <Compile Include="..\Masuit.Tools.Abstractions\Files\INIFile.cs">
       <Link>Files\INIFile.cs</Link>
     </Compile>
-    <Compile Include="..\Masuit.Tools.Abstractions\Files\WinrarHelper.cs">
-      <Link>Files\WinrarHelper.cs</Link>
-    </Compile>
     <Compile Include="..\Masuit.Tools.Abstractions\Hardware\CpuInfo.cs">
       <Link>Hardware\CpuInfo.cs</Link>
     </Compile>

+ 0 - 12
Masuit.Tools/Masuit.Tools.csproj

@@ -47,9 +47,6 @@
     <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
   </PropertyGroup>
   <ItemGroup>
-    <Compile Include="..\Masuit.Tools.Abstractions\Database\DataExt.cs">
-      <Link>Database\DataExt.cs</Link>
-    </Compile>
     <Compile Include="..\Masuit.Tools.Abstractions\Database\DataTableBuilder.cs">
       <Link>Database\DataTableBuilder.cs</Link>
     </Compile>
@@ -65,12 +62,6 @@
     <Compile Include="..\Masuit.Tools.Abstractions\DateTimeExt\DateTimeHelper.cs">
       <Link>DateTimeExt\DateTimeHelper.cs</Link>
     </Compile>
-    <Compile Include="..\Masuit.Tools.Abstractions\DateTimeExt\DateUtil.cs">
-      <Link>DateTimeExt\DateUtil.cs</Link>
-    </Compile>
-    <Compile Include="..\Masuit.Tools.Abstractions\DateTimeExt\TimeHelper.cs">
-      <Link>DateTimeExt\TimeHelper.cs</Link>
-    </Compile>
     <Compile Include="..\Masuit.Tools.Abstractions\DateTimeExt\WeekHolidayStruct.cs">
       <Link>DateTimeExt\WeekHolidayStruct.cs</Link>
     </Compile>
@@ -122,9 +113,6 @@
     <Compile Include="..\Masuit.Tools.Abstractions\Files\INIFile.cs">
       <Link>Files\INIFile.cs</Link>
     </Compile>
-    <Compile Include="..\Masuit.Tools.Abstractions\Files\WinrarHelper.cs">
-      <Link>Files\WinrarHelper.cs</Link>
-    </Compile>
     <Compile Include="..\Masuit.Tools.Abstractions\Hardware\CpuInfo.cs">
       <Link>Hardware\CpuInfo.cs</Link>
     </Compile>