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

Function localtime_from_timestamp

crates/vm/src/stdlib/time.rs:1161–1171  ·  view source on GitHub ↗
(
        when: time_t,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

1159
1160 #[cfg_attr(target_env = "musl", allow(deprecated))]
1161 pub(super) fn localtime_from_timestamp(
1162 when: time_t,
1163 vm: &VirtualMachine,
1164 ) -> PyResult<StructTimeData> {
1165 let mut out = core::mem::MaybeUninit::<libc::tm>::uninit();
1166 let ret = unsafe { libc::localtime_r(&when, out.as_mut_ptr()) };
1167 if ret.is_null() {
1168 return Err(vm.new_overflow_error("timestamp out of range for platform time_t"));
1169 }
1170 Ok(struct_time_from_tm(vm, unsafe { out.assume_init() }))
1171 }
1172
1173 pub(super) fn unix_mktime(t: &StructTimeData, vm: &VirtualMachine) -> PyResult<f64> {
1174 let mut tm = super::decl::tm_from_struct_time(t, vm)?;

Callers 4

localtimeFunction · 0.85
asctimeFunction · 0.85
ctimeFunction · 0.85
strftimeFunction · 0.85

Calls 5

struct_time_from_tmFunction · 0.85
get_tz_infoFunction · 0.85
as_mut_ptrMethod · 0.80
ErrClass · 0.50
iterMethod · 0.45

Tested by

no test coverage detected