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

Method naive_or_local

crates/vm/src/stdlib/time.rs:332–339  ·  view source on GitHub ↗

Construct a localtime from the optional seconds, or get the current local time.

(self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

330 impl OptionalArg<Option<Either<f64, i64>>> {
331 /// Construct a localtime from the optional seconds, or get the current local time.
332 fn naive_or_local(self, vm: &VirtualMachine) -> PyResult<NaiveDateTime> {
333 Ok(match self {
334 Self::Present(Some(secs)) => pyobj_to_date_time(secs, vm)?
335 .with_timezone(&chrono::Local)
336 .naive_local(),
337 Self::Present(None) | Self::Missing => chrono::offset::Local::now().naive_local(),
338 })
339 }
340 }
341
342 #[cfg(any(unix, windows))]

Callers 4

localtimeFunction · 0.80
asctimeFunction · 0.80
ctimeFunction · 0.80
strftimeFunction · 0.80

Calls 2

pyobj_to_date_timeFunction · 0.85
to_date_timeMethod · 0.80

Tested by

no test coverage detected