8000 Datetime fix for MinGW. by 87 · Pull Request #214 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Datetime fix for MinGW. #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ENH: Add get_mktime function to support multiple platforms.
  • Loading branch information
87 committed Feb 20, 2012
commit c401afd379e6a46ae33330fe782ef2b31ef7b686
31 changes: 31 additions & 0 deletions numpy/core/src/multiarray/datetime_strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,37 @@ get_gmtime(NPY_TIME_T *ts, struct tm *tms)
return -1;
}

/*
* Wraps `mktime` functionality for multiple platforms. This
* converts a local time struct to an UTC value.
*
* Returns timestamp on success, -1 on failure.
*/
static NPY_TIME_T
get_mktime(struct tm *tms)
{
char *func_name = "<unknown>";
NPY_TIME_T ts;
#if defined(NPY_MINGW_USE_CUSTOM_MSVCR)
ts = _mktime64(tms);
if (ts == -1) {
func_name = "_mktime64";
goto fail;
}
#else
ts = mktime(tms)
if (ts == -1) {
func_name = "mktime";
goto fail;
}
#endif
return ts;
fail:
PyErr_Format(PyExc_OSError, "Failed to use '%s' to convert "
"local time to UTC", func_name);
return -1;
}

/*
* Converts a datetimestruct in UTC to a datetimestruct in local time,
* also returning the timezone offset applied.
Expand Down
0