diff --git a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs index 6f2623694..16e4155c4 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs @@ -90,6 +90,9 @@ namespace IRaCIS.Core.API } } + ////如果前端传递带时区的,那么转换会报错,需要DateTimeKind.Unspecified + //dateTime = DateTime.SpecifyKind(dateTime, DateTimeKind.Unspecified); + // 将客户端时间转换为服务器时区的时间 var serverZoneTime = TimeZoneInfo.ConvertTime(dateTime, _clientTimeZone, TimeZoneInfo.Local); @@ -109,6 +112,10 @@ namespace IRaCIS.Core.API DateTime clientZoneTime = TimeZoneInfo.ConvertTime(nullableDateTime.Value, _clientTimeZone); + //// 最简单的方式:创建 DateTimeOffset + //DateTimeOffset dateTimeOffset = new DateTimeOffset(clientZoneTime, _clientTimeZone.GetUtcOffset(clientZoneTime)); + //writer.WriteValue(dateTimeOffset.ToString("yyyy-MM-dd HH:mm:sszzz")); + writer.WriteValue(clientZoneTime.ToString(_dateFormat)); } else