diff --git a/src/kits/network/libnetservices/HttpTime.cpp b/src/kits/network/libnetservices/HttpTime.cpp index 11ee02d728..8ab42be535 100644 --- a/src/kits/network/libnetservices/HttpTime.cpp +++ b/src/kits/network/libnetservices/HttpTime.cpp @@ -12,6 +12,7 @@ #include #include +#include // The formats used should be, in order of preference (according to RFC2616, @@ -47,6 +48,8 @@ static const char* kDateFormats[] = { "%a %d %b %H:%M:%S %Y" }; +static locale_t posix = newlocale(LC_ALL_MASK, "POSIX", (locale_t)0); + #ifdef LIBNETAPI_DEPRECATED using namespace BPrivate; #else @@ -109,6 +112,10 @@ BHttpTime::Parse() memset(&expireTime, 0, sizeof(struct tm)); + // Save the current locale, switch to POSIX for strptime to match strings + // in English, switch back when we're done. + locale_t current = uselocale(posix); + fDateFormat = B_HTTP_TIME_FORMAT_PARSED; unsigned int i; for (i = 0; i < sizeof(kDateFormats) / sizeof(const char*); @@ -125,6 +132,8 @@ BHttpTime::Parse() } } + uselocale(current); + // Did we identify some valid format? if (fDateFormat == B_HTTP_TIME_FORMAT_PARSED) return 0;