File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3439,10 +3439,18 @@ fn fn_now_server(_args: Vec<CfmlValue>) -> CfmlResult {
34393439 Ok ( CfmlValue :: String ( Local :: now ( ) . format ( "%Y-%m-%d %H:%M:%S" ) . to_string ( ) ) )
34403440}
34413441
3442- fn fn_get_tick_count ( _args : Vec < CfmlValue > ) -> CfmlResult {
3442+ fn fn_get_tick_count ( args : Vec < CfmlValue > ) -> CfmlResult {
34433443 use std:: time:: { SystemTime , UNIX_EPOCH } ;
3444- let ms = SystemTime :: now ( ) . duration_since ( UNIX_EPOCH ) . unwrap ( ) . as_millis ( ) as i64 ;
3445- Ok ( CfmlValue :: Int ( ms) )
3444+ let duration = SystemTime :: now ( ) . duration_since ( UNIX_EPOCH ) . unwrap ( ) ;
3445+ let unit = args. first ( )
3446+ . and_then ( |v| if let CfmlValue :: String ( s) = v { Some ( s. to_lowercase ( ) ) } else { None } )
3447+ . unwrap_or_else ( || "milli" . to_string ( ) ) ;
3448+ let val = match unit. as_str ( ) {
3449+ "nano" => duration. as_nanos ( ) as i64 ,
3450+ "second" => duration. as_secs ( ) as i64 ,
3451+ _ => duration. as_millis ( ) as i64 ,
3452+ } ;
3453+ Ok ( CfmlValue :: Int ( val) )
34463454}
34473455
34483456fn fn_get_function_list ( _args : Vec < CfmlValue > ) -> CfmlResult {
You can’t perform that action at this time.
0 commit comments