From 38122c22241cb8fe64f0d17cd3b084418f49edaa Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 28 Feb 2009 04:54:54 -0400 Subject: Corrected warnings g++-4.3.3 was complaining about --- src/py_times.cc | 67 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 19 deletions(-) (limited to 'src/py_times.cc') diff --git a/src/py_times.cc b/src/py_times.cc index f209929a..45e7391d 100644 --- a/src/py_times.cc +++ b/src/py_times.cc @@ -63,14 +63,21 @@ struct date_from_python return 0; } - static void construct(PyObject* obj_ptr, converter::rvalue_from_python_stage1_data* data) + static void construct(PyObject * obj_ptr, + converter::rvalue_from_python_stage1_data * data) { MY_PyDateTime_IMPORT; - int y = PyDateTime_GET_YEAR(obj_ptr); - int m = PyDateTime_GET_MONTH(obj_ptr); - int d = PyDateTime_GET_DAY(obj_ptr); - date* dte = new date(y,m,d); - data->convertible = (void*)dte; + + int year = PyDateTime_GET_YEAR(obj_ptr); + date::year_type y = gregorian::greg_year(static_cast(year)); + date::month_type m = + static_cast(PyDateTime_GET_MONTH(obj_ptr)); + date::day_type d = + static_cast(PyDateTime_GET_DAY(obj_ptr)); + + date * dte = new date(y, m, d); + + data->convertible = (void *) dte; } }; @@ -83,11 +90,15 @@ struct datetime_to_python static PyObject* convert(const datetime_t& moment) { MY_PyDateTime_IMPORT; + date dte = moment.date(); datetime_t::time_duration_type tod = moment.time_of_day(); - return PyDateTime_FromDateAndTime(dte.year(), dte.month(), dte.day(), - tod.hours(), tod.minutes(), tod.seconds(), - tod.total_microseconds() % 1000000); + + return PyDateTime_FromDateAndTime + (static_cast(dte.year()), static_cast(dte.month()), + static_cast(dte.day()), static_cast(tod.hours()), + static_cast(tod.minutes()), static_cast(tod.seconds()), + static_cast(tod.total_microseconds() % 1000000)); } }; @@ -100,18 +111,36 @@ struct datetime_from_python return 0; } - static void construct(PyObject* obj_ptr, converter::rvalue_from_python_stage1_data* data) + static void construct(PyObject * obj_ptr, + converter::rvalue_from_python_stage1_data * data) { MY_PyDateTime_IMPORT; - int y = PyDateTime_GET_YEAR(obj_ptr); - int m = PyDateTime_GET_MONTH(obj_ptr); - int d = PyDateTime_GET_DAY(obj_ptr); - int h = PyDateTime_DATE_GET_HOUR(obj_ptr); - int min = PyDateTime_DATE_GET_MINUTE(obj_ptr); - int s = PyDateTime_DATE_GET_SECOND(obj_ptr); - datetime_t* moment = new datetime_t(date(y,m,d), - datetime_t::time_duration_type(h, min, s)); - data->convertible = (void*)moment; + + int year = PyDateTime_GET_YEAR(obj_ptr); + date::year_type y = gregorian::greg_year(static_cast(year)); + date::month_type m = + static_cast(PyDateTime_GET_MONTH(obj_ptr)); + date::day_type d = + static_cast(PyDateTime_GET_DAY(obj_ptr)); + + datetime_t::time_duration_type::hour_type h = + static_cast + (PyDateTime_DATE_GET_HOUR(obj_ptr)); + datetime_t::time_duration_type::min_type min = + static_cast + (PyDateTime_DATE_GET_MINUTE(obj_ptr)); + datetime_t::time_duration_type::sec_type s = + static_cast + (PyDateTime_DATE_GET_SECOND(obj_ptr)); + datetime_t::time_duration_type::fractional_seconds_type ms = + static_cast + (PyDateTime_DATE_GET_MICROSECOND(obj_ptr)) * 1000000; + + datetime_t * moment + = new datetime_t(date(y, m, d), + datetime_t::time_duration_type(h, min, s, ms)); + + data->convertible = (void *) moment; } }; -- cgit v1.2.3