Skip to content

Commit

Permalink
Merge pull request #35 from jaroslawp/master
Browse files Browse the repository at this point in the history
fix traceback on non-complete datetime information (python)
  • Loading branch information
Tojaj committed Sep 29, 2015
2 parents 3c97a65 + 95e9f62 commit 7e4e307
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/python/updaterecord-py.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,12 @@ get_datetime(_UpdateRecordObject *self, void *member_offset)

struct tm *dt = malloc(sizeof(struct tm));
char *res = strptime(str, "%Y-%m-%d %H:%M:%S", dt);
if (res == NULL)
PyErr_SetString(CrErr_Exception, "Invalid date");

if (res == NULL) {
memset(res,0,sizeof(dt));
res = strptime(str, "%Y-%m-%d", dt);
if (res == NULL)
PyErr_SetString(CrErr_Exception, "Invalid date");
}
PyObject *py_dt = PyDateTime_FromDateAndTime(dt->tm_year + 1900,
dt->tm_mon + 1, dt->tm_mday,
dt->tm_hour, dt->tm_min, dt->tm_sec, 0);
Expand Down

0 comments on commit 7e4e307

Please sign in to comment.