diff --git a/Cesium.Compiler/stdlib/time.h b/Cesium.Compiler/stdlib/time.h new file mode 100644 index 00000000..5a7774d7 --- /dev/null +++ b/Cesium.Compiler/stdlib/time.h @@ -0,0 +1,6 @@ +#pragma once + +typedef long time_t; + +__cli_import("Cesium.Runtime.TimeFunctions::Time") +time_t time(time_t* arg); diff --git a/Cesium.Runtime/TimeFunctions.cs b/Cesium.Runtime/TimeFunctions.cs new file mode 100644 index 00000000..2cc195e5 --- /dev/null +++ b/Cesium.Runtime/TimeFunctions.cs @@ -0,0 +1,15 @@ +namespace Cesium.Runtime; + +public static unsafe class TimeFunctions +{ + public static long Time(long* time) + { + var result = (DateTime.UtcNow - new DateTime(0)).TotalSeconds; + if (time is not null) + { + *time = (long)result; + } + + return (long)result; + } +}