Explorar el Código

Merge pull request #289 from Librelancer/fix_os_clock

Fix OsTimeModule.clock returning nil at application start
Kevin Morgan hace 4 años
padre
commit
65e4bd1550
Se han modificado 1 ficheros con 3 adiciones y 1 borrados
  1. 3 1
      src/MoonSharp.Interpreter/CoreLib/OsTimeModule.cs

+ 3 - 1
src/MoonSharp.Interpreter/CoreLib/OsTimeModule.cs

@@ -35,7 +35,9 @@ namespace MoonSharp.Interpreter.CoreLib
 		[MoonSharpModuleMethod]
 		public static DynValue clock(ScriptExecutionContext executionContext, CallbackArguments args)
 		{
-			return GetUnixTime(DateTime.UtcNow, Time0);
+			var t = GetUnixTime(DateTime.UtcNow, Time0);
+			if (t.IsNil()) return DynValue.NewNumber(0.0);
+			return t;
 		}
 
 		[MoonSharpModuleMethod]