| 300 | } |
| 301 | |
| 302 | Status PyDateTime_from_int(int64_t val, const TimeUnit::type unit, PyObject** out) { |
| 303 | int64_t hour = 0, minute = 0, second = 0, microsecond = 0; |
| 304 | RETURN_NOT_OK(PyTime_convert_int(val, unit, &hour, &minute, &second, µsecond)); |
| 305 | int64_t total_days = 0; |
| 306 | hour = split_time(hour, 24, &total_days); |
| 307 | int64_t year = 0, month = 0, day = 0; |
| 308 | get_date_from_days(total_days, &year, &month, &day); |
| 309 | *out = PyDateTime_FromDateAndTime( |
| 310 | static_cast<int32_t>(year), static_cast<int32_t>(month), static_cast<int32_t>(day), |
| 311 | static_cast<int32_t>(hour), static_cast<int32_t>(minute), |
| 312 | static_cast<int32_t>(second), static_cast<int32_t>(microsecond)); |
| 313 | return Status::OK(); |
| 314 | } |
| 315 | |
| 316 | int64_t PyDate_to_days(PyDateTime_Date* pydate) { |
| 317 | return get_days_from_date(PyDateTime_GET_YEAR(pydate), PyDateTime_GET_MONTH(pydate), |
no test coverage detected