Skip to content

Commit 29e6cf7

Browse files
committed
add DateTime Convertible
1 parent 5d2c959 commit 29e6cf7

2 files changed

Lines changed: 16 additions & 17 deletions

File tree

‎CSharp.lua/CoreSystem.Lua/CoreSystem/Convert.lua‎

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -288,22 +288,6 @@ local function throwInvalidCastException()
288288
throw(InvalidCastException())
289289
end
290290

291-
local Int = System.Int
292-
Int.ToBoolean = toBoolean
293-
Int.ToChar = toChar
294-
Int.ToSByte = toSByte
295-
Int.ToByte = toByte
296-
Int.ToInt16 = toInt16
297-
Int.ToUInt16 = toUInt16
298-
Int.ToInt32 = toInt32
299-
Int.ToUInt32 = toUInt32
300-
Int.ToInt64 = toInt64
301-
Int.ToUInt64 = toUInt64
302-
Int.ToSingle = toSingle
303-
Int.ToDouble = toDouble
304-
Int.ToDateTime = throwInvalidCastException
305-
Int.ToType = defaultToType
306-
307291
local Number = System.Number
308292
Number.ToBoolean = toBoolean
309293
Number.ToChar = toChar
@@ -334,3 +318,18 @@ Boolean.ToSingle = toSingle
334318
Boolean.ToDouble = toDouble
335319
Boolean.ToDateTime = throwInvalidCastException
336320
Boolean.ToType = defaultToType
321+
322+
DateTime.ToBoolean = throwInvalidCastException
323+
DateTime.ToChar = throwInvalidCastException
324+
DateTime.ToSByte = throwInvalidCastException
325+
DateTime.ToByte = throwInvalidCastException
326+
DateTime.ToInt16 = throwInvalidCastException
327+
DateTime.ToUInt16 = throwInvalidCastException
328+
DateTime.ToInt32 = throwInvalidCastException
329+
DateTime.ToUInt32 = throwInvalidCastException
330+
DateTime.ToInt64 = throwInvalidCastException
331+
DateTime.ToUInt64 = throwInvalidCastException
332+
DateTime.ToSingle = throwInvalidCastException
333+
DateTime.ToDouble = throwInvalidCastException
334+
DateTime.ToDateTime = identityFn
335+
DateTime.ToType = defaultToType

‎CSharp.lua/CoreSystem.Lua/CoreSystem/DateTime.lua‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ function DateTime.__le(t1, t2)
458458
end
459459

460460
function DateTime.__inherits__()
461-
return { System.IComparable, System.IComparable_1(DateTime), System.IEquatable_1(DateTime) }
461+
return { System.IComparable, System.IComparable_1(DateTime), System.IConvertible, System.IEquatable_1(DateTime) }
462462
end
463463

464464
System.defStc("System.DateTime", DateTime)

0 commit comments

Comments
 (0)