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

Function localtime

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

Source from the content-addressed store, hash-verified

543
544 #[pyfunction]
545 fn localtime(
546 secs: OptionalArg<Option<Either<f64, i64>>>,
547 vm: &VirtualMachine,
548 ) -> PyResult<StructTimeData> {
549 #[cfg(any(unix, windows))]
550 {
551 let ts = match secs {
552 OptionalArg::Present(Some(value)) => pyobj_to_time_t(value, vm)?,
553 OptionalArg::Present(None) | OptionalArg::Missing => current_time_t(),
554 };
555 localtime_from_timestamp(ts, vm)
556 }
557
558 #[cfg(not(any(unix, windows)))]
559 let instant = secs.naive_or_local(vm)?;
560 #[cfg(not(any(unix, windows)))]
561 {
562 Ok(StructTimeData::new_local(vm, instant, 0))
563 }
564 }
565
566 #[pyfunction]
567 fn mktime(t: StructTimeData, vm: &VirtualMachine) -> PyResult<f64> {

Callers

nothing calls this directly

Calls 4

pyobj_to_time_tFunction · 0.85
current_time_tFunction · 0.85
localtime_from_timestampFunction · 0.85
naive_or_localMethod · 0.80

Tested by

no test coverage detected