| 319 | } |
| 320 | |
| 321 | Result<int64_t> PyDateTime_utcoffset_s(PyObject* obj) { |
| 322 | // calculate offset from UTC timezone in seconds |
| 323 | // supports only PyDateTime_DateTime and PyDateTime_Time objects |
| 324 | OwnedRef pyoffset(PyObject_CallMethod(obj, "utcoffset", NULL)); |
| 325 | RETURN_IF_PYERROR(); |
| 326 | if (pyoffset.obj() != nullptr && pyoffset.obj() != Py_None) { |
| 327 | auto delta = reinterpret_cast<PyDateTime_Delta*>(pyoffset.obj()); |
| 328 | return internal::PyDelta_to_s(delta); |
| 329 | } else { |
| 330 | return 0; |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | Result<std::string> PyTZInfo_utcoffset_hhmm(PyObject* pytzinfo) { |
| 335 | // attempt to convert timezone offset objects to "+/-{hh}:{mm}" format |