Skip to content

Commit e2d6fff

Browse files
committed
[1.5.2]修复SetObject中String->DateTime相关的转换错误
1 parent 7448df3 commit e2d6fff

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

LinePutScript/SetObject.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,18 @@ public DateTime GetDateTime()
267267
case ObjectType.Float:
268268
return new DateTime((long)(double)Value);
269269
case ObjectType.String:
270-
return DateTime.Parse((string)Value);
270+
if (long.TryParse((string)Value, out long r))
271+
{
272+
return new DateTime(r);
273+
}
274+
else if (DateTime.TryParse((string)Value, out DateTime result))
275+
{
276+
return result;
277+
}
278+
else
279+
{
280+
return DateTime.MinValue;
281+
}
271282
case ObjectType.Boolean:
272283
return (bool)Value ? DateTime.MaxValue : DateTime.MinValue;
273284
case ObjectType.DateTime:

nuget/LinePutScript.1.5.2.nupkg

209 KB
Binary file not shown.

0 commit comments

Comments
 (0)