MCPcopy Index your code
hub / github.com/RustPython/RustPython / ctime

Function ctime

crates/vm/src/stdlib/time.rs:620–637  ·  view source on GitHub ↗
(secs: OptionalArg<Option<Either<f64, i64>>>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

618
619 #[pyfunction]
620 fn ctime(secs: OptionalArg<Option<Either<f64, i64>>>, vm: &VirtualMachine) -> PyResult<String> {
621 #[cfg(any(unix, windows))]
622 {
623 let ts = match secs {
624 OptionalArg::Present(Some(value)) => pyobj_to_time_t(value, vm)?,
625 OptionalArg::Present(None) | OptionalArg::Missing => current_time_t(),
626 };
627 let local = localtime_from_timestamp(ts, vm)?;
628 let tm = checked_tm_from_struct_time(&local, vm, "asctime")?.tm;
629 Ok(asctime_from_tm(&tm))
630 }
631
632 #[cfg(not(any(unix, windows)))]
633 {
634 let instant = secs.naive_or_local(vm)?;
635 Ok(instant.format(CFMT).to_string())
636 }
637 }
638
639 #[cfg(any(unix, windows))]
640 fn strftime_crt(format: &PyStrRef, checked_tm: CheckedTm, vm: &VirtualMachine) -> PyResult {

Callers

nothing calls this directly

Calls 8

pyobj_to_time_tFunction · 0.85
current_time_tFunction · 0.85
localtime_from_timestampFunction · 0.85
asctime_from_tmFunction · 0.85
naive_or_localMethod · 0.80
to_stringMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected