8000 Win32 build by mwiebe · Pull Request #118 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Win32 build #118

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 4 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
8000 Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
BUG: datetime: Use gmtime and localtime for mingw
These functions allegedly use thread-local storage on mingw,
so hopefully it's ok.
  • Loading branch information
Mark Wiebe committed Jul 21, 2011
commit ea6ae36bf7a1729890b24d0f80f2da3eb9099edf
48 changes: 45 additions & 3 deletions numpy/core/src/multiarray/datetime_strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,21 @@ parse_iso_8601_datetime(char *str, int len,
struct tm tm_;

time(&rawtime);
#if defined(_WIN32) && !defined(__GNUC__)
#if defined(_WIN32) && defined(__GNUC__)
struct tm * tm_ptr;
/*
* MINGW supports neither localtime_s nor localtime_r, but
* supposedly uses thread-local storage, so this should
* be ok.
*/
tm_ptr = localtime(&rawtime);
if (tm_ptr == NULL) {
PyErr_SetString(PyExc_OSError, "Failed to use localtime to "
"get a local time");
return -1;
}
tm_ = *tm_ptr;
#elif defined(_WIN32)
if (localtime_s(&tm_, &rawtime) != 0) {
PyErr_SetString(PyExc_OSError, "Failed to obtain local time "
"from localtime_s");
Expand Down Expand Up @@ -532,7 +546,21 @@ parse_iso_8601_datetime(char *str, int len,
}

/* gmtime converts a 'time_t' into a UTC 'struct tm' */
#if defined(_WIN32) && !defined(__GNUC__)
#if defined(_WIN32) && defined(__GNUC__)
struct tm * tm_ptr;
/*
* MINGW supports neither gmtime_s nor gmtime_r, but
* supposedly uses thread-local storage, so this should
* be ok.
*/
tm_ptr = gmtime(&rawtime);
if (tm_ptr == NULL) {
PyErr_SetString(PyExc_OSError, "Failed to use gmtime to "
"get a UTC time");
goto error;
}
tm_ = *tm_ptr;
#elif defined(_WIN32)
if (gmtime_s(&tm_, &rawtime) != 0) {
PyErr_SetString(PyExc_OSError, "Failed to use gmtime_s to "
"get a UTC time");
Expand Down Expand Up @@ -884,7 +912,21 @@ make_iso_8601_datetime(npy_datetimestruct *dts, char *outstr, int outlen,
rawtime += dts->min * 60;

/* localtime converts a 'time_t' into a local 'struct tm' */
#if defined(_WIN32) && !defined(__GNUC__)
#if defined(_WIN32) && defined(__GNUC__)
struct tm * tm_ptr;
/*
* MINGW supports neither localtime_s nor localtime_r, but
* supposedly uses thread-local storage, so this should
* be ok.
*/
tm_ptr = localtime(&rawtime);
if (tm_ptr == NULL) {
PyErr_SetString(PyExc_OSError, "Failed to use localtime to "
"get a local time");
return -1;
}
tm_ = *tm_ptr;
#elif defined(_WIN32)
if (localtime_s(&tm_, &rawtime) != 0) {
PyErr_SetString(PyExc_OSError, "Failed to use localtime_s to "
"get a local time");
Expand Down
0