File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -41,18 +41,19 @@ namespace pybind11 { namespace detail {
41
41
42
42
std::time_t tt = src.seconds_since_epoch ();
43
43
std::tm localtime = *std::gmtime (&tt);
44
-
45
44
handle pydate = PyDateTime_FromDateAndTime (localtime .tm_year + 1900 ,
46
- localtime .tm_mon + 1 ,
47
- localtime .tm_mday ,
48
- localtime .tm_hour ,
49
- localtime .tm_min ,
50
- localtime .tm_sec ,
51
- 0 );
52
-
53
- auto utc = pybind11::module::import (" datetime" ).attr (" timezone" ).attr (" utc" );
54
- using namespace pybind11 ::literals;
55
- return pydate.attr (" replace" )(" tzinfo" _a=utc).inc_ref ();
45
+ localtime .tm_mon + 1 ,
46
+ localtime .tm_mday ,
47
+ localtime .tm_hour ,
48
+ localtime .tm_min ,
49
+ localtime .tm_sec ,
50
+ 0 );
51
+
52
+ static auto utc = module::import (" datetime" ).attr (" timezone" ).attr (" utc" );
53
+ using namespace literals ;
54
+ handle with_utc = pydate.attr (" replace" )(" tzinfo" _a=utc).inc_ref ();
55
+ pydate.dec_ref ();
56
+ return with_utc;
56
57
}
57
58
58
59
PYBIND11_TYPE_CASTER (type, _(" datetime.datetime" ));
You can’t perform that action at this time.
0 commit comments