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

Method to_date_time

crates/vm/src/stdlib/time.rs:927–943  ·  view source on GitHub ↗
(&self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

925
926 #[cfg(not(any(unix, windows)))]
927 fn to_date_time(&self, vm: &VirtualMachine) -> PyResult<NaiveDateTime> {
928 let invalid_overflow = || vm.new_overflow_error("mktime argument out of range");
929 let invalid_value = || vm.new_value_error("invalid struct_time parameter");
930
931 macro_rules! field {
932 ($field:ident) => {
933 self.$field.clone().try_into_value(vm)?
934 };
935 }
936 let dt = NaiveDateTime::new(
937 NaiveDate::from_ymd_opt(field!(tm_year), field!(tm_mon), field!(tm_mday))
938 .ok_or_else(invalid_value)?,
939 NaiveTime::from_hms_opt(field!(tm_hour), field!(tm_min), field!(tm_sec))
940 .ok_or_else(invalid_overflow)?,
941 );
942 Ok(dt)
943 }
944 }
945
946 #[pyattr]

Callers 2

naive_or_localMethod · 0.80
mktimeFunction · 0.80

Calls 2

newFunction · 0.85
ok_or_elseMethod · 0.80

Tested by

no test coverage detected