Skip to content

Commit 7b84f61

Browse files
authored
Fix bugs in datetime parsing (#35)
1 parent 84f1eed commit 7b84f61

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

include/pytomlpp/toml_types.hpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ template <> class type_caster<toml::date> {
2222
toml::date d;
2323

2424
if (PyDate_Check(src.ptr())) {
25-
d.year = PyDateTime_GET_DAY(src.ptr());
25+
d.year = PyDateTime_GET_YEAR(src.ptr());
2626
d.month = PyDateTime_GET_MONTH(src.ptr());
27-
d.day = PyDateTime_GET_YEAR(src.ptr());
27+
d.day = PyDateTime_GET_DAY(src.ptr());
2828
} else
2929
return false;
3030

@@ -99,15 +99,15 @@ template <> class type_caster<toml::date_time> {
9999

100100
if (PyDateTime_Check(src.ptr())) {
101101
toml::date d;
102-
d.year = PyDateTime_GET_DAY(src.ptr());
102+
d.year = PyDateTime_GET_YEAR(src.ptr());
103103
d.month = PyDateTime_GET_MONTH(src.ptr());
104-
d.day = PyDateTime_GET_YEAR(src.ptr());
104+
d.day = PyDateTime_GET_DAY(src.ptr());
105105

106106
toml::time t;
107-
t.hour = PyDateTime_TIME_GET_HOUR(src.ptr());
108-
t.minute = PyDateTime_TIME_GET_MINUTE(src.ptr());
109-
t.second = PyDateTime_TIME_GET_SECOND(src.ptr());
110-
t.nanosecond = PyDateTime_TIME_GET_MICROSECOND(src.ptr()) * 1000;
107+
t.hour = PyDateTime_DATE_GET_HOUR(src.ptr());
108+
t.minute = PyDateTime_DATE_GET_MINUTE(src.ptr());
109+
t.second = PyDateTime_DATE_GET_SECOND(src.ptr());
110+
t.nanosecond = PyDateTime_DATE_GET_MICROSECOND(src.ptr()) * 1000;
111111

112112
py::object tz_info = src.attr("tzinfo");
113113

0 commit comments

Comments
 (0)