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

Function struct_time_from_tm

crates/vm/src/stdlib/time.rs:1117–1140  ·  view source on GitHub ↗
(vm: &VirtualMachine, tm: libc::tm)

Source from the content-addressed store, hash-verified

1115 }
1116
1117 fn struct_time_from_tm(vm: &VirtualMachine, tm: libc::tm) -> StructTimeData {
1118 let zone = unsafe {
1119 if tm.tm_zone.is_null() {
1120 String::new()
1121 } else {
1122 core::ffi::CStr::from_ptr(tm.tm_zone)
1123 .to_string_lossy()
1124 .into_owned()
1125 }
1126 };
1127 StructTimeData {
1128 tm_year: vm.ctx.new_int(tm.tm_year + 1900).into(),
1129 tm_mon: vm.ctx.new_int(tm.tm_mon + 1).into(),
1130 tm_mday: vm.ctx.new_int(tm.tm_mday).into(),
1131 tm_hour: vm.ctx.new_int(tm.tm_hour).into(),
1132 tm_min: vm.ctx.new_int(tm.tm_min).into(),
1133 tm_sec: vm.ctx.new_int(tm.tm_sec).into(),
1134 tm_wday: vm.ctx.new_int((tm.tm_wday + 6) % 7).into(),
1135 tm_yday: vm.ctx.new_int(tm.tm_yday + 1).into(),
1136 tm_isdst: vm.ctx.new_int(tm.tm_isdst).into(),
1137 tm_zone: vm.ctx.new_str(zone).into(),
1138 tm_gmtoff: vm.ctx.new_int(tm.tm_gmtoff).into(),
1139 }
1140 }
1141
1142 #[cfg_attr(target_env = "musl", allow(deprecated))]
1143 pub(super) fn current_time_t() -> time_t {

Callers 2

gmtime_from_timestampFunction · 0.85
localtime_from_timestampFunction · 0.85

Calls 5

newFunction · 0.85
into_ownedMethod · 0.80
to_string_lossyMethod · 0.45
new_intMethod · 0.45
new_strMethod · 0.45

Tested by

no test coverage detected