Skip to content

Commit

Permalink
FIX: Use the NPY_TIME_T macro everywhere
Browse files Browse the repository at this point in the history
Previously, two (critical) parts of the code used `time_t` instead of
`NPY_TIME_T`. Due to the fact, that most of the time `NPY_TIME_T` was equal to
`time_t`, this bug didn't show up. But in mingw, `NPY_TIME_T` is actually equal
to `__time64_t` and then this causes 64 bit integers to be cast into 32 bit
integers (thus becoming negative), which causes localtime() to fail in mingw.

Fixes numpygh-568.
  • Loading branch information
certik committed Dec 27, 2012
1 parent db671db commit 15022cb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions numpy/core/src/multiarray/datetime_strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ convert_datetimestruct_utc_to_local(npy_datetimestruct *out_dts_local,
* we drop the seconds value from the npy_datetimestruct, everything
* is ok for this operation.
*/
rawtime = (time_t)get_datetimestruct_days(out_dts_local) * 24 * 60 * 60;
rawtime = (NPY_TIME_T)get_datetimestruct_days(out_dts_local) * 24 * 60 * 60;
rawtime += dts_utc->hour * 60 * 60;
rawtime += dts_utc->min * 60;

Expand All @@ -207,7 +207,7 @@ convert_datetimestruct_utc_to_local(npy_datetimestruct *out_dts_local,

/* Extract the timezone offset that was applied */
rawtime /= 60;
localrawtime = (time_t)get_datetimestruct_days(out_dts_local) * 24 * 60;
localrawtime = (NPY_TIME_T)get_datetimestruct_days(out_dts_local) * 24 * 60;
localrawtime += out_dts_local->hour * 60;
localrawtime += out_dts_local->min;

Expand Down

0 comments on commit 15022cb

Please sign in to comment.