From d724f7f21c5cc8c5dd5aa0cf7345a62a662eb2bf Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期三, 16 十二月 2020 15:12:18 +0800
Subject: [PATCH] 2020-12-16 1.子账号和解锁部分接口增加Loading处理

---
 HDL_ON/Common/Utlis.cs |   63 +++++++++++++++++++++++++++----
 1 files changed, 55 insertions(+), 8 deletions(-)

diff --git a/HDL_ON/Common/Utlis.cs b/HDL_ON/Common/Utlis.cs
index 4597fc4..62cb24e 100644
--- a/HDL_ON/Common/Utlis.cs
+++ b/HDL_ON/Common/Utlis.cs
@@ -2,15 +2,13 @@
 using Shared;
 using System.Text.RegularExpressions;
 using System.Text;
-using System.Collections.Generic;
-using System.Collections;
 
 namespace HDL_ON
 {
     /// <summary>
     /// 甯哥敤宸ュ叿绫�
     /// </summary>
-    public class Utlis
+    public static class Utlis
     {
 		/// <summary>
 		/// 鍏ㄥ眬鎵撳嵃
@@ -305,15 +303,16 @@
 		}
 
 		/// <summary>
-		/// 鑾峰彇褰撳墠鏃堕棿鎴冲��
-		/// </summary>
-		/// <returns></returns>
+        /// 
+        /// </summary>
+        /// <param name="isMilliseconds">鏄惁寰</param>
+        /// <returns></returns>
 		public static string GetTimestamp(bool isMilliseconds = true)
 		{
 			System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 褰撳湴鏃跺尯
 			if (isMilliseconds)
 			{
-				return ((long)(DateTime.Now - startTime).TotalMilliseconds).ToString(); // 鐩稿樊绉掓暟
+				return ((long)(DateTime.Now - startTime).TotalMilliseconds).ToString(); // 鐩稿樊寰鏁�
 			}
 			else
 			{
@@ -329,7 +328,55 @@
 			return Language.CurrentLanguage == "Chinese" ? LanguageTypeEnum.CHINESE.ToString() : LanguageTypeEnum.ENGLISH.ToString();
 		}
 
-		
+
+		#region 鏃堕棿鏍煎紡杞崲
+		private const int Second = 1;
+		private const int Minute = 60 * Second;
+		private const int Hour = 60 * Minute;
+		private const int Day = 24 * Hour;
+		private const int Month = 30 * Day;
+
+		/// <summary>
+		/// 鏃堕棿杞崲
+		/// 灏戜簬1澶�  鏄剧ず 鏃跺垎
+		/// 灏戜簬涓�骞� 鏄剧ず 鏈堟棩
+		/// 澶т簬涓�骞� 鏄剧ず 骞�
+		/// </summary>
+		/// <param name="dateTime"></param>
+		/// <returns></returns>
+		public static string ToFriendlyDisplay(this DateTime dateTime)
+		{
+			var ts = DateTime.Now - dateTime;
+			var delta = ts.TotalSeconds;
+			if (delta < 24 * Hour)
+			{
+				//鏄剧ず 鏃�:鍒�
+				return dateTime.ToString("HH:mm");
+			}
+			else if (delta < 12 * Month)
+			{
+				//鏄剧ず 鏈�:鏃�
+				return dateTime.ToString("MM/dd");
+			}
+			else
+			{   //鏄剧ず 骞�
+				return dateTime.ToString("yyyy");
+			}
+		}
+		/// <summary>
+		/// 鏃堕棿杞崲
+		/// 灏戜簬1澶�  鏄剧ず 鏃跺垎
+		/// 灏戜簬涓�骞� 鏄剧ず 鏈堟棩
+		/// 澶т簬涓�骞� 鏄剧ず 骞�
+		/// </summary>
+		/// <param name="dateTime"></param>
+		/// <returns></returns>
+		public static string ToFriendlyDisplay(long unixTimeStamp)
+		{
+			return ToFriendlyDisplay(UnixToDateTimeMS(unixTimeStamp));
+		}
+		#endregion
+
 	}
 
 

--
Gitblit v1.8.0