Skip to content

Commit 0506461

Browse files
committed
fix time
1 parent 151722e commit 0506461

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/bee/lua_time.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ fn bee_time_time(_: &Lua, _: ()) -> LuaResult<i64> {
1010
Ok(timestamp)
1111
}
1212

13+
lazy_static! {
14+
static ref START_TIME: Instant = Instant::now();
15+
}
16+
1317
fn bee_time_monotonic(_: &Lua, _: ()) -> LuaResult<i64> {
14-
let duration = Instant::now().elapsed();
18+
// 获取当前时间与起始时间的差值
19+
let duration = START_TIME.elapsed();
1520
let timestamp = duration.as_millis() as i64;
1621
Ok(timestamp)
1722
}

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async fn main() -> LuaResult<()> {
2424
}
2525

2626
build_args(&lua);
27-
let main = lua.load(path::Path::new("resources/main.lua"));
27+
let main = lua.load(path::Path::new("resources/testmain.lua"));
2828
main.call_async(()).await?;
2929
Ok(())
3030
}

0 commit comments

Comments
 (0)