From 7e810df1295aa2cf5fdeff49c6351f50eaa49cc8 Mon Sep 17 00:00:00 2001 From: Liumt <1012750881@qq.com> Date: Mon, 9 Sep 2024 13:49:33 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90OpenApi=E3=80=91=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=BC=80=E6=94=BE=E6=8E=A5=E5=8F=A3=E6=97=B6=E9=97=B4=E6=88=B3?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=88=A4=E6=96=AD=E7=A7=92=E5=92=8C=E6=AF=AB?= =?UTF-8?q?=E7=A7=92=E7=9A=84=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SignatureAuthenticationHandler.cs | 2 +- Admin.NET/Admin.NET.Core/Util/DateTimeUtil.cs | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Admin.NET/Admin.NET.Core/SignatureAuth/SignatureAuthenticationHandler.cs b/Admin.NET/Admin.NET.Core/SignatureAuth/SignatureAuthenticationHandler.cs index e6beeae6..753c2f82 100644 --- a/Admin.NET/Admin.NET.Core/SignatureAuth/SignatureAuthenticationHandler.cs +++ b/Admin.NET/Admin.NET.Core/SignatureAuth/SignatureAuthenticationHandler.cs @@ -67,7 +67,7 @@ public sealed class SignatureAuthenticationHandler : AuthenticationHandler + /// 根据unix时间戳的长度自动判断是秒还是以毫秒为单位 + /// + /// + /// + public static DateTime ConvertUnixTime(long unixTime) + { + // 判断时间戳长度 + bool isMilliseconds = unixTime > 9999999999; + + if (isMilliseconds) + { + return DateTimeOffset.FromUnixTimeMilliseconds(unixTime).ToLocalTime().DateTime; + } + else + { + return DateTimeOffset.FromUnixTimeSeconds(unixTime).ToLocalTime().DateTime; + } + } + /// /// 获取开始时间 ///