解决中英文环境时间格式化问题
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-08-26 12:28:09 +09:00
parent e42c7407e3
commit fbc7513f19
5 changed files with 123 additions and 133 deletions
@@ -2,6 +2,8 @@
using Newtonsoft.Json;
using System;
using SharpCompress.Writers;
using IRaCIS.Core.Domain.Share;
using System.Globalization;
namespace IRaCIS.Core.API._ServiceExtensions.NewtonsoftJson
{
@@ -77,6 +79,37 @@ namespace IRaCIS.Core.API._ServiceExtensions.NewtonsoftJson
return deserializedObj!;
}
public static string DateTimeInternationalToString(DateTime? dateTime, string? clientZoneId=null)
{
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
if (dateTime.HasValue)
{
var needDealTime = dateTime.Value;
if (!string.IsNullOrWhiteSpace(clientZoneId))
{
needDealTime = TimeZoneInfo.ConvertTime(needDealTime, TimeZoneInfo.Local, TimeZoneInfo.FindSystemTimeZoneById(clientZoneId));
}
if (isEn_US)
{
//暂时保持一致,等需求确认,修改英文要展示的日期格式
return needDealTime.ToString("yyyy-MM-dd HH:mm:ss");
}
else
{
return needDealTime.ToString("yyyy-MM-dd HH:mm:ss");
}
}
else
{
return string.Empty;
}
}
}
}