Skip to content

Commit

Permalink
Add time.h (#750)
Browse files Browse the repository at this point in the history
  • Loading branch information
kant2002 authored Dec 4, 2024
1 parent 7b32d92 commit 6232c81
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Cesium.Compiler/stdlib/time.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

typedef long time_t;

__cli_import("Cesium.Runtime.TimeFunctions::Time")
time_t time(time_t* arg);
15 changes: 15 additions & 0 deletions Cesium.Runtime/TimeFunctions.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 6232c81

Please sign in to comment.