From a414550ca6347c8c736d3dade41cae0803e796fc Mon Sep 17 00:00:00 2001 From: "DESKTOP-B25GA9E\\W35" <1733709035@qq.com> Date: Mon, 30 Jan 2023 17:26:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=88=B3=E5=B0=8F=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/MsgTransmitTools/util.meta | 8 ++++ .../MsgTransmitTools/util/SystemDateUtil.cs | 39 +++++++++++++++++++ .../util/SystemDateUtil.cs.meta | 11 ++++++ 3 files changed, 58 insertions(+) create mode 100644 Assets/MsgTransmitTools/util.meta create mode 100644 Assets/MsgTransmitTools/util/SystemDateUtil.cs create mode 100644 Assets/MsgTransmitTools/util/SystemDateUtil.cs.meta diff --git a/Assets/MsgTransmitTools/util.meta b/Assets/MsgTransmitTools/util.meta new file mode 100644 index 0000000..a8c4653 --- /dev/null +++ b/Assets/MsgTransmitTools/util.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e8289e2d510119c47a6cad58f893ecd4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/MsgTransmitTools/util/SystemDateUtil.cs b/Assets/MsgTransmitTools/util/SystemDateUtil.cs new file mode 100644 index 0000000..a75b077 --- /dev/null +++ b/Assets/MsgTransmitTools/util/SystemDateUtil.cs @@ -0,0 +1,39 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using System; +using System.Globalization; + +namespace JXSoft { + public class SystemDateUtil + { + public const string FULL_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; + public const string DATE_FORMAT = "yyyy-MM-dd"; + public const string TIME_FORMAT = "HH:mm:ss"; + public static string getFullDateMsg() + { + return DateTime.Now.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToString("HH:mm:ss"); + } + public static string getDayDateMsg() + { + return DateTime.Now.ToString("HH:mm:ss"); + } + public static long getTimeStamp() { + TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 8, 0, 0, 0); + return Convert.ToInt64(ts.TotalSeconds); + } + + public static string getFullTimeFromTimeStamp(string timeStamp) { + DateTime dateTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); + long lTime = long.Parse(timeStamp + "0000000"); + TimeSpan toNow = new TimeSpan(lTime); + dateTime = dateTime.Add(toNow); + return dateTime.ToString("yyyy-MM-dd") + " " + dateTime.ToString("HH:mm:ss"); + } + + public static DateTime getDateTimeFromFullStr(string dateString, string formatString) { + DateTime dateTime = DateTime.ParseExact(dateString, formatString, CultureInfo.InvariantCulture); + return dateTime; + } + } +} \ No newline at end of file diff --git a/Assets/MsgTransmitTools/util/SystemDateUtil.cs.meta b/Assets/MsgTransmitTools/util/SystemDateUtil.cs.meta new file mode 100644 index 0000000..790ee87 --- /dev/null +++ b/Assets/MsgTransmitTools/util/SystemDateUtil.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f4dd550ee73bc424d9949220d6f7c37f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: