MCPcopy Create free account
hub / github.com/aiscriptdev/aiscript / time_unix_timestamp

Function time_unix_timestamp

aiscript-vm/src/stdlib/time.rs:62–73  ·  view source on GitHub ↗

Returns the Unix timestamp in seconds for a given time string

(
    _state: &mut State<'gc>,
    args: Vec<Value<'gc>>,
)

Source from the content-addressed store, hash-verified

60
61/// Returns the Unix timestamp in seconds for a given time string
62fn time_unix_timestamp<'gc>(
63 _state: &mut State<'gc>,
64 args: Vec<Value<'gc>>,
65) -> Result<Value<'gc>, VmError> {
66 let time_str = string_arg!(&args, 0, "unix_timestamp")?;
67
68 // Parse the datetime string (assumes ISO 8601 format)
69 let dt = DateTime::parse_from_rfc3339(time_str.to_str().unwrap())
70 .map_err(|e| VmError::RuntimeError(format!("Failed to parse timestamp: {}", e)))?;
71
72 Ok(Value::Number(dt.timestamp() as f64))
73}
74
75/// Sleeps for the specified number of seconds
76fn time_sleep<'gc>(_state: &mut State<'gc>, args: Vec<Value<'gc>>) -> Result<Value<'gc>, VmError> {

Callers

nothing calls this directly

Calls 2

RuntimeErrorClass · 0.85
to_strMethod · 0.80

Tested by

no test coverage detected