(t: OptionalArg<StructTimeData>, vm: &VirtualMachine)
| 593 | |
| 594 | #[pyfunction] |
| 595 | fn asctime(t: OptionalArg<StructTimeData>, vm: &VirtualMachine) -> PyResult { |
| 596 | #[cfg(any(unix, windows))] |
| 597 | { |
| 598 | let tm = match t { |
| 599 | OptionalArg::Present(value) => { |
| 600 | checked_tm_from_struct_time(&value, vm, "asctime")?.tm |
| 601 | } |
| 602 | OptionalArg::Missing => { |
| 603 | let now = current_time_t(); |
| 604 | let local = localtime_from_timestamp(now, vm)?; |
| 605 | checked_tm_from_struct_time(&local, vm, "asctime")?.tm |
| 606 | } |
| 607 | }; |
| 608 | Ok(vm.ctx.new_str(asctime_from_tm(&tm)).into()) |
| 609 | } |
| 610 | |
| 611 | #[cfg(not(any(unix, windows)))] |
| 612 | { |
| 613 | let instant = t.naive_or_local(vm)?; |
| 614 | let formatted_time = instant.format(CFMT).to_string(); |
| 615 | Ok(vm.ctx.new_str(formatted_time).into()) |
| 616 | } |
| 617 | } |
| 618 | |
| 619 | #[pyfunction] |
| 620 | fn ctime(secs: OptionalArg<Option<Either<f64, i64>>>, vm: &VirtualMachine) -> PyResult<String> { |
nothing calls this directly
no test coverage detected