Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 7648776

Browse files
add a unix_timestamp extern (tgstation#122)
Co-authored-by: Mothblocks <[email protected]>
1 parent acfc252 commit 7648776

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

dmsrc/time.dm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
#define rustg_time_microseconds(id) text2num(RUSTG_CALL(RUST_G, "time_microseconds")(id))
22
#define rustg_time_milliseconds(id) text2num(RUSTG_CALL(RUST_G, "time_milliseconds")(id))
33
#define rustg_time_reset(id) RUSTG_CALL(RUST_G, "time_reset")(id)
4+
5+
/proc/rustg_unix_timestamp()
6+
return text2num(RUSTG_CALL(RUST_G, "unix_timestamp")())

src/time.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,15 @@ byond_fn!(fn time_reset(instant_id) {
3535
Some("")
3636
})
3737
});
38+
39+
byond_fn!(
40+
fn unix_timestamp() {
41+
Some(
42+
std::time::SystemTime::now()
43+
.duration_since(std::time::UNIX_EPOCH)
44+
.unwrap()
45+
.as_secs_f64()
46+
.to_string(),
47+
)
48+
}
49+
);

0 commit comments

Comments
 (0)