* 重命名UTC1970/1/1为Jan1st1970
This commit is contained in:
parent
3b1a5b6649
commit
e281846a3e
BIN
Bin/SunnyUI.dll
BIN
Bin/SunnyUI.dll
Binary file not shown.
BIN
Bin/SunnyUI.pdb
BIN
Bin/SunnyUI.pdb
Binary file not shown.
Binary file not shown.
@ -93,8 +93,8 @@ namespace Sunny.UI
|
||||
get => item.Date;
|
||||
set
|
||||
{
|
||||
if (value < DateTimeEx.DateTimeBegin)
|
||||
value = DateTimeEx.DateTimeBegin;
|
||||
if (value < DateTimeEx.Jan1st1970)
|
||||
value = DateTimeEx.Jan1st1970;
|
||||
Text = value.ToString(dateFormat);
|
||||
item.Date = value;
|
||||
}
|
||||
|
@ -113,8 +113,8 @@ namespace Sunny.UI
|
||||
get => item.Date;
|
||||
set
|
||||
{
|
||||
if (value < DateTimeEx.DateTimeBegin)
|
||||
value = DateTimeEx.DateTimeBegin;
|
||||
if (value < DateTimeEx.Jan1st1970)
|
||||
value = DateTimeEx.Jan1st1970;
|
||||
Text = value.ToString(dateFormat);
|
||||
item.Date = value;
|
||||
}
|
||||
|
@ -249,18 +249,13 @@ namespace Sunny.UI
|
||||
/// <returns>浮点</returns>
|
||||
public static double ToDouble(this DateTime datetime)
|
||||
{
|
||||
return datetime.Subtract(DateTimeBegin).TotalDays;
|
||||
return datetime.Subtract(Jan1st1970).TotalDays;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 起始日期,UTC时间,1970-01-01 00:00:00起始
|
||||
/// </summary>
|
||||
public static DateTime DateTimeBegin = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
/// <summary>
|
||||
/// 日期最大值
|
||||
/// </summary>
|
||||
public static DateTime DateTimeEnd = new DateTime(9999, 12, 31, 23, 59, 59, 999, DateTimeKind.Utc);
|
||||
public static DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
/// <summary>
|
||||
/// 浮点转时间日期,以UTC时间,1970-01-01 00:00:00起始
|
||||
@ -269,7 +264,7 @@ namespace Sunny.UI
|
||||
/// <returns>日期</returns>
|
||||
public static DateTime ToDateTime(this double iDays)
|
||||
{
|
||||
return TimeZone.CurrentTimeZone.ToLocalTime(DateTimeBegin.AddDays(iDays));
|
||||
return TimeZone.CurrentTimeZone.ToLocalTime(Jan1st1970.AddDays(iDays));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -444,7 +439,7 @@ namespace Sunny.UI
|
||||
/// </remarks>
|
||||
public static long SecondsSince1970(this DateTime datetime)
|
||||
{
|
||||
TimeSpan ts = datetime.ToUniversalTime().Subtract(DateTimeBegin);
|
||||
TimeSpan ts = datetime.ToUniversalTime().Subtract(Jan1st1970);
|
||||
return (long)ts.TotalSeconds;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ namespace Sunny.UI
|
||||
public long Value { get; set; }
|
||||
|
||||
public const long Jan1st1970Ticks = 621355968000000000; //Jan1st1970.Ticks;
|
||||
public const long Dec31th9999Ticks = 3155378975999990000; //Dec31th9999.Ticks;
|
||||
public const long Dec31th9999Ticks = 3155378975999990000; //DateTime.MaxValue.Ticks;
|
||||
public const string DefaultFormatString = DateTimeEx.DateTimeFormatEx;
|
||||
|
||||
/// <summary>
|
||||
|
@ -172,7 +172,7 @@ namespace Sunny.UI
|
||||
SnowflakeIDDetail result = new SnowflakeIDDetail();
|
||||
result.SnowflakeID = Id;
|
||||
var timestamp = (Id >> timestampLeftShift);
|
||||
var time = DateTimeEx.DateTimeBegin.AddMilliseconds(timestamp + twepoch);
|
||||
var time = DateTimeEx.Jan1st1970.AddMilliseconds(timestamp + twepoch);
|
||||
result.DateTime = time.ToLocalTime();
|
||||
result.DataCenterID = (Id ^ (timestamp << timestampLeftShift)) >> datacenterIdShift;
|
||||
result.WorkerID = (Id ^ ((timestamp << timestampLeftShift) | (result.DataCenterID << datacenterIdShift))) >> workerIdShift;
|
||||
@ -201,7 +201,7 @@ namespace Sunny.UI
|
||||
/// <returns></returns>
|
||||
private static long GetCurrentTimestamp()
|
||||
{
|
||||
return (long)(DateTime.UtcNow - DateTimeEx.DateTimeBegin).TotalMilliseconds;
|
||||
return (long)(DateTime.UtcNow - DateTimeEx.Jan1st1970).TotalMilliseconds;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user