Skip to content

Commit c3fb13c

Browse files
author
梶塚太智
committed
Update main.rs
1 parent e85ddf8 commit c3fb13c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/main.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ use powershell_script::PsScriptBuilder;
22
use rand::seq::SliceRandom;
33
use std::collections::HashMap;
44
use std::env;
5+
use std::thread::sleep;
56
use std::fs::File;
67
use std::io::{self, Error, Read, Write};
8+
use std::time::{SystemTime, Duration, UNIX_EPOCH};
79

810
fn main() {
911
// コマンドライン引数を読み込む
@@ -794,6 +796,22 @@ impl Executor {
794796
self.stack.push(a);
795797
}
796798

799+
// 日付処理
800+
801+
// 現在時刻を取得
802+
"now-time" => {
803+
self.stack.push(Type::Number(
804+
SystemTime::now()
805+
.duration_since(UNIX_EPOCH)
806+
.unwrap()
807+
.as_secs_f64(),
808+
));
809+
}
810+
811+
"sleep" => {
812+
sleep(Duration::from_secs_f64(self.pop_stack().get_number()))
813+
}
814+
797815
// コマンドとして認識されない場合は文字列とする
798816
_ => self.stack.push(Type::String(command)),
799817
}

0 commit comments

Comments
 (0)