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

Function asctime

crates/vm/src/stdlib/time.rs:595–617  ·  view source on GitHub ↗
(t: OptionalArg<StructTimeData>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

593
594 #[pyfunction]
595 fn asctime(t: OptionalArg<StructTimeData>, vm: &VirtualMachine) -> PyResult {
596 #[cfg(any(unix, windows))]
597 {
598 let tm = match t {
599 OptionalArg::Present(value) => {
600 checked_tm_from_struct_time(&value, vm, "asctime")?.tm
601 }
602 OptionalArg::Missing => {
603 let now = current_time_t();
604 let local = localtime_from_timestamp(now, vm)?;
605 checked_tm_from_struct_time(&local, vm, "asctime")?.tm
606 }
607 };
608 Ok(vm.ctx.new_str(asctime_from_tm(&tm)).into())
609 }
610
611 #[cfg(not(any(unix, windows)))]
612 {
613 let instant = t.naive_or_local(vm)?;
614 let formatted_time = instant.format(CFMT).to_string();
615 Ok(vm.ctx.new_str(formatted_time).into())
616 }
617 }
618
619 #[pyfunction]
620 fn ctime(secs: OptionalArg<Option<Either<f64, i64>>>, vm: &VirtualMachine) -> PyResult<String> {

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected