mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-25 02:10:16 +00:00
增加Chart的useUtc参数设置显示时间是否用UTC时间
This commit is contained in:
@@ -31,6 +31,11 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to use UTC time for the chart.
|
||||
/// ||图表的时间是否都显示为UTC时间。
|
||||
/// </summary>
|
||||
public bool useUtc { get { return m_UseUtc; } set { m_UseUtc = value; } }
|
||||
/// <summary>
|
||||
/// The theme.
|
||||
/// ||</summary>
|
||||
public ThemeStyle theme { get { return m_Theme; } set { m_Theme = value; } }
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace XCharts.Runtime
|
||||
public partial class BaseChart : BaseGraph, ISerializationCallbackReceiver
|
||||
{
|
||||
[SerializeField] protected string m_ChartName;
|
||||
[SerializeField] protected bool m_UseUtc = true;
|
||||
[SerializeField] protected ThemeStyle m_Theme = new ThemeStyle();
|
||||
[SerializeField] protected Settings m_Settings;
|
||||
[SerializeField] protected DebugInfo m_DebugInfo = new DebugInfo();
|
||||
|
||||
@@ -100,9 +100,9 @@ namespace XCharts.Runtime
|
||||
return NumberToStr(value, numericFormatter);
|
||||
}
|
||||
|
||||
public static string NumberToDateStr(double timestamp, string formatter)
|
||||
public static string NumberToDateStr(double timestamp, string formatter, bool local = false)
|
||||
{
|
||||
var dt = NumberToDateTime(timestamp);
|
||||
var dt = NumberToDateTime(timestamp, local);
|
||||
try
|
||||
{
|
||||
return dt.ToString(formatter, ci);
|
||||
@@ -132,11 +132,11 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
public static DateTime NumberToDateTime(double timestamp)
|
||||
public static DateTime NumberToDateTime(double timestamp, bool local = false)
|
||||
{
|
||||
if (!s_TimestampToDateTimeDict.ContainsKey(timestamp))
|
||||
{
|
||||
s_TimestampToDateTimeDict[timestamp] = DateTimeUtil.GetDateTime(timestamp);
|
||||
s_TimestampToDateTimeDict[timestamp] = DateTimeUtil.GetDateTime(timestamp, local);
|
||||
}
|
||||
return s_TimestampToDateTimeDict[timestamp];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user