SlHelpers
Toggle main menu visibility
Loading...
Searching...
No Matches
pybindSupp.h
1
// SPDX-License-Identifier: GPL-2.0-only
2
3
#pragma once
4
5
#include <chrono>
6
7
#include <pybind11/pybind11.h>
8
9
namespace
pybind11::detail {
10
12
template
<>
struct
type_caster<std::chrono::year_month_day> {
14
PYBIND11_TYPE_CASTER
(std::chrono::year_month_day, _(
"datetime.date"
));
16
static
handle
cast
(std::chrono::year_month_day ymd, return_value_policy, handle) {
17
return
pybind11::module_::import(
"datetime"
).attr(
"date"
)(
18
int(ymd.year()),
19
unsigned(ymd.month()),
20
unsigned(ymd.day())
21
).release();
22
}
23
};
24
25
}
pybind11::detail::type_caster< std::chrono::year_month_day >::cast
static handle cast(std::chrono::year_month_day ymd, return_value_policy, handle)
Casts a std::chrono::year_month_day to a Python datetime.date object.
Definition
pybindSupp.h:16
pybind11::detail::type_caster< std::chrono::year_month_day >::PYBIND11_TYPE_CASTER
PYBIND11_TYPE_CASTER(std::chrono::year_month_day, _("datetime.date"))
The necessary boilerplate for casting std::chrono::year_month_day to Python.
src
pybind
pybindSupp.h
Generated by
1.17.0