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

Method new_local

crates/vm/src/stdlib/time.rs:919–924  ·  view source on GitHub ↗
(vm: &VirtualMachine, tm: NaiveDateTime, isdst: i32)

Source from the content-addressed store, hash-verified

917 /// Create struct_time for local timezone (localtime)
918 #[cfg(not(any(unix, windows)))]
919 fn new_local(vm: &VirtualMachine, tm: NaiveDateTime, isdst: i32) -> Self {
920 let local_time = chrono::Local.from_local_datetime(&tm).unwrap();
921 let offset_seconds = local_time.offset().local_minus_utc();
922 let tz_abbr = local_time.format("%Z").to_string();
923 Self::new_inner(vm, tm, isdst, offset_seconds, &tz_abbr)
924 }
925
926 #[cfg(not(any(unix, windows)))]
927 fn to_date_time(&self, vm: &VirtualMachine) -> PyResult<NaiveDateTime> {

Callers

nothing calls this directly

Calls 4

to_stringMethod · 0.80
unwrapMethod · 0.45
offsetMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected