(vm: &VirtualMachine, tm: libc::tm)
| 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 { |
no test coverage detected