Browse Source

添加日期验证工具

yuzhengyang 8 years ago
parent
commit
69a0ded08c

+ 6 - 3
Fork.Net/Y.Utils/DataUtils/DateTimeUtils/DateTimeTool.cs

@@ -1,7 +1,10 @@
-//############################################################
+//************************************************************************
 //      https://github.com/yuzhengyang
 //      https://github.com/yuzhengyang
-//      author:yuzhengyang
-//############################################################
+//      author:     yuzhengyang
+//      date:       2017.3.29 - 2017.8.17
+//      desc:       日期时间工具
+//      Copyright (c) yuzhengyang. All rights reserved.
+//************************************************************************
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;

+ 32 - 0
Fork.Net/Y.Utils/DataUtils/DateTimeUtils/DateTool.cs

@@ -0,0 +1,32 @@
+//************************************************************************
+//      https://github.com/yuzhengyang
+//      author:     yuzhengyang
+//      date:       2017.8.17 - 2017.8.17
+//      desc:       日期工具
+//      Copyright (c) yuzhengyang. All rights reserved.
+//************************************************************************
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Y.Utils.DataUtils.DateTimeUtils
+{
+    public sealed class DateTool
+    {
+        public static bool IsToday(DateTime date)
+        {
+            DateTime today = DateTime.Now;
+            if (today.Year == date.Year && today.Month == date.Month && today.Day == date.Day)
+                return true;
+            return false;
+        }
+        public static bool IsYesterday(DateTime date)
+        {
+            DateTime yesterday = DateTime.Now.AddDays(-1);
+            if (yesterday.Year == date.Year && yesterday.Month == date.Month && yesterday.Day == date.Day)
+                return true;
+            return false;
+        }
+    }
+}

+ 1 - 0
Fork.Net/Y.Utils/Y.Utils.csproj

@@ -53,6 +53,7 @@
   <ItemGroup>
   <ItemGroup>
     <Compile Include="AppUtils\AppLaunchTool.cs" />
     <Compile Include="AppUtils\AppLaunchTool.cs" />
     <Compile Include="AppUtils\AppUnique.cs" />
     <Compile Include="AppUtils\AppUnique.cs" />
+    <Compile Include="DataUtils\DateTimeUtils\DateTool.cs" />
     <Compile Include="UpdateUtils\AppUpdateInfo.cs" />
     <Compile Include="UpdateUtils\AppUpdateInfo.cs" />
     <Compile Include="UpdateUtils\AppUpdateTool.cs" />
     <Compile Include="UpdateUtils\AppUpdateTool.cs" />
     <Compile Include="DataUtils\RandomUtils\RandomTool.cs" />
     <Compile Include="DataUtils\RandomUtils\RandomTool.cs" />