[change] 使用int64存储datetime类型,避免读取日期超过2038年出现问题 (#38)
parent
ea30f8c202
commit
ae87bf3f52
|
|
@ -179,7 +179,7 @@ namespace Luban.Job.Cfg.DataExporters
|
||||||
|
|
||||||
public void Accept(DDateTime type, ByteBuf x)
|
public void Accept(DDateTime type, ByteBuf x)
|
||||||
{
|
{
|
||||||
x.WriteInt(type.UnixTimeOfCurrentAssembly);
|
x.WriteLong(type.UnixTimeOfCurrentAssembly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ namespace Luban.Job.Cfg.DataExporters
|
||||||
|
|
||||||
public void Accept(DDateTime type, CodedOutputStream x)
|
public void Accept(DDateTime type, CodedOutputStream x)
|
||||||
{
|
{
|
||||||
x.WriteInt32(type.UnixTimeOfCurrentAssembly);
|
x.WriteInt64(type.UnixTimeOfCurrentAssembly);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Accept(DString type, CodedOutputStream x)
|
public void Accept(DString type, CodedOutputStream x)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ namespace Luban.Job.Cfg.Datas
|
||||||
public DateTime Time { get; }
|
public DateTime Time { get; }
|
||||||
|
|
||||||
//public int UnixTime { get; }
|
//public int UnixTime { get; }
|
||||||
private readonly int _localTime;
|
private readonly long _localTime;
|
||||||
|
|
||||||
public override string TypeName => "datetime";
|
public override string TypeName => "datetime";
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Luban.Job.Cfg.Datas
|
||||||
this.Time = time;
|
this.Time = time;
|
||||||
// time.Kind == DateTimeKind.Unspecified
|
// time.Kind == DateTimeKind.Unspecified
|
||||||
// DateTimeOffset°ÑËüµ±×÷Local´¦Àí
|
// DateTimeOffset°ÑËüµ±×÷Local´¦Àí
|
||||||
this._localTime = (int)new DateTimeOffset(TimeZoneInfo.ConvertTime(time, TimeZoneUtil.DefaultTimeZone, TimeZoneInfo.Utc)).ToUnixTimeSeconds();
|
this._localTime = (long)new DateTimeOffset(TimeZoneInfo.ConvertTime(time, TimeZoneUtil.DefaultTimeZone, TimeZoneInfo.Utc)).ToUnixTimeSeconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
|
|
@ -48,7 +48,7 @@ namespace Luban.Job.Cfg.Datas
|
||||||
return DataUtil.FormatDateTime(Time);
|
return DataUtil.FormatDateTime(Time);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetUnixTime(TimeZoneInfo asTimeZone)
|
public long GetUnixTime(TimeZoneInfo asTimeZone)
|
||||||
{
|
{
|
||||||
if (asTimeZone == null || asTimeZone == TimeZoneInfo.Local)
|
if (asTimeZone == null || asTimeZone == TimeZoneInfo.Local)
|
||||||
{
|
{
|
||||||
|
|
@ -57,11 +57,11 @@ namespace Luban.Job.Cfg.Datas
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var destDateTime = TimeZoneInfo.ConvertTime(Time, asTimeZone, TimeZoneInfo.Utc);
|
var destDateTime = TimeZoneInfo.ConvertTime(Time, asTimeZone, TimeZoneInfo.Utc);
|
||||||
return (int)new DateTimeOffset(destDateTime).ToUnixTimeSeconds();
|
return (long)new DateTimeOffset(destDateTime).ToUnixTimeSeconds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int UnixTimeOfCurrentAssembly => GetUnixTime(DefAssembly.LocalAssebmly.TimeZone);
|
public long UnixTimeOfCurrentAssembly => GetUnixTime(DefAssembly.LocalAssebmly.TimeZone);
|
||||||
|
|
||||||
public override void Apply<T>(IDataActionVisitor<T> visitor, T x)
|
public override void Apply<T>(IDataActionVisitor<T> visitor, T x)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type, string bufName, string fieldName)
|
public string Accept(TDateTime type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"if(!{bufName}.readInt({fieldName})) return false;";
|
return $"if(!{bufName}.readLong({fieldName})) return false;";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type, string json, string x, int depth)
|
public string Accept(TDateTime type, string json, string x, int depth)
|
||||||
{
|
{
|
||||||
return $"{x} = {json}.GetInt32();";
|
return $"{x} = {json}.GetInt64();";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type, string json, string x, int depth)
|
public string Accept(TDateTime type, string json, string x, int depth)
|
||||||
{
|
{
|
||||||
return $"{x} = {json}.getAsInt();";
|
return $"{x} = {json}.getAsLong();";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type, string bufName, string fieldName)
|
public string Accept(TDateTime type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{fieldName} = {bufName}.readInt();";
|
return $"{fieldName} = {bufName}.readLong();";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type, string jsonVarName)
|
public string Accept(TDateTime type, string jsonVarName)
|
||||||
{
|
{
|
||||||
return AsType(jsonVarName, "i32");
|
return AsType(jsonVarName, "i64");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type)
|
public string Accept(TDateTime type)
|
||||||
{
|
{
|
||||||
return "int32";
|
return "int64";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
{
|
{
|
||||||
return mapper.TargetTypeName;
|
return mapper.TargetTypeName;
|
||||||
}
|
}
|
||||||
return "int";
|
return "long";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type, string bufName, string fieldName, int depth)
|
public string Accept(TDateTime type, string bufName, string fieldName, int depth)
|
||||||
{
|
{
|
||||||
string src = $"{bufName}.ReadInt()";
|
string src = $"{bufName}.ReadLong()";
|
||||||
return $"{fieldName} = {ExternalTypeUtil.CsCloneToExternal("datetime", src)};";
|
return $"{fieldName} = {ExternalTypeUtil.CsCloneToExternal("datetime", src)};";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type, string bufName, string fieldName)
|
public string Accept(TDateTime type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{bufName}.WriteInt({fieldName});";
|
return $"{bufName}.WriteLong({fieldName});";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type)
|
public string Accept(TDateTime type)
|
||||||
{
|
{
|
||||||
return "int32";
|
return "int64";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TBean type)
|
public string Accept(TBean type)
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type, string fieldName, string bufName, string err)
|
public string Accept(TDateTime type, string fieldName, string bufName, string err)
|
||||||
{
|
{
|
||||||
return $"{{ if {fieldName}, {err} = {bufName}.ReadInt(); {err} != nil {{ {err} = errors.New(\"{fieldName} error\"); return }} }}";
|
return $"{{ if {fieldName}, {err} = {bufName}.ReadLong(); {err} != nil {{ {err} = errors.New(\"{fieldName} error\"); return }} }}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TBean type, string fieldName, string bufName, string err)
|
public string Accept(TBean type, string fieldName, string bufName, string err)
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type, string fieldName, string bufName)
|
public string Accept(TDateTime type, string fieldName, string bufName)
|
||||||
{
|
{
|
||||||
return $"{bufName}.WriteInt({fieldName})";
|
return $"{bufName}.WriteLong({fieldName})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TBean type, string fieldName, string bufName)
|
public string Accept(TBean type, string fieldName, string bufName)
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type)
|
public string Accept(TDateTime type)
|
||||||
{
|
{
|
||||||
return "int32";
|
return "int64";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public override string Accept(TDateTime type)
|
public override string Accept(TDateTime type)
|
||||||
{
|
{
|
||||||
return "Integer";
|
return "Long";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Accept(TEnum type)
|
public override string Accept(TEnum type)
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public virtual string Accept(TDateTime type)
|
public virtual string Accept(TDateTime type)
|
||||||
{
|
{
|
||||||
return type.IsNullable ? "Integer" : "int";
|
return type.IsNullable ? "Long" : "long";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type, string bufName, string fieldName, int depth)
|
public string Accept(TDateTime type, string bufName, string fieldName, int depth)
|
||||||
{
|
{
|
||||||
return $"{fieldName} = {bufName}.readInt();";
|
return $"{fieldName} = {bufName}.readLong();";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type, string bufName, string fieldName)
|
public string Accept(TDateTime type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{bufName}.writeInt({fieldName});";
|
return $"{bufName}.writeLong({fieldName});";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type)
|
public string Accept(TDateTime type)
|
||||||
{
|
{
|
||||||
return "readInt";
|
return "readLong";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type)
|
public string Accept(TDateTime type)
|
||||||
{
|
{
|
||||||
return "writeInt";
|
return "writeLong";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type)
|
public string Accept(TDateTime type)
|
||||||
{
|
{
|
||||||
return "int32";
|
return "int64";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TBean type)
|
public string Accept(TBean type)
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type)
|
public string Accept(TDateTime type)
|
||||||
{
|
{
|
||||||
return "i32";
|
return "i64";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type)
|
public string Accept(TDateTime type)
|
||||||
{
|
{
|
||||||
return "INT";
|
return "LONG";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type, string bufVarName, string fieldName)
|
public string Accept(TDateTime type, string bufVarName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{fieldName} = {bufVarName}.ReadInt()";
|
return $"{fieldName} = {bufVarName}.ReadLong()";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ namespace Luban.Job.Common.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type, string bufVarName, string fieldName)
|
public string Accept(TDateTime type, string bufVarName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{bufVarName}.WriteInt({fieldName})";
|
return $"{bufVarName}.WriteLong({fieldName})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string Accept(TBean type, string bufVarName, string fieldName)
|
public virtual string Accept(TBean type, string bufVarName, string fieldName)
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ namespace Luban.Job.Db.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type, string bufName, string fieldName)
|
public string Accept(TDateTime type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
return $"{fieldName} = {bufName}.ReadInt();";
|
return $"{fieldName} = {bufName}.ReadLong();";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -150,9 +150,9 @@ namespace Luban.Job.Db.TypeVisitors
|
||||||
return $"{bufName}.WriteVector4({fieldName});";
|
return $"{bufName}.WriteVector4({fieldName});";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TDateTime type, string x, string y)
|
public string Accept(TDateTime type, string bufName, string fieldName)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return $"{bufName}.WriteLong({fieldName});";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ namespace Luban.Job.Db.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type)
|
public string Accept(TDateTime type)
|
||||||
{
|
{
|
||||||
return "Bright.Common.SerializationUtil.DeserializeInt";
|
return "Bright.Common.SerializationUtil.DeserializeLong";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ namespace Luban.Job.Db.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type, string fieldName)
|
public string Accept(TDateTime type, string fieldName)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
return $"{fieldName} = default;";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ namespace Luban.Job.Db.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type)
|
public string Accept(TDateTime type)
|
||||||
{
|
{
|
||||||
return "Bright.Common.SerializationUtil.SerializeInt";
|
return "Bright.Common.SerializationUtil.SerializeLong";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ namespace Luban.Job.Db.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type)
|
public string Accept(TDateTime type)
|
||||||
{
|
{
|
||||||
return "SerializeFactory.deserializeInt";
|
return "SerializeFactory.deserializeLong";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,9 +130,10 @@ namespace Luban.Job.Db.TypeVisitors
|
||||||
return $"{fieldName} = new Vector4()";
|
return $"{fieldName} = new Vector4()";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(TDateTime type, string x, string y)
|
public string Accept(TDateTime type, string fieldName, string logType
|
||||||
|
)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
return $"{fieldName} = 0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ namespace Luban.Job.Db.TypeVisitors
|
||||||
|
|
||||||
public string Accept(TDateTime type)
|
public string Accept(TDateTime type)
|
||||||
{
|
{
|
||||||
return "SerializeFactory.serializeInt";
|
return "SerializeFactory.serializeLong";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue