Commit 660ff241 authored by eric@webkit.org's avatar eric@webkit.org

2010-02-02 Kwang Yul Seo <skyul@company100.net>

        Reviewed by Eric Seidel.

        Use WTF::getLocalTime instead of localtime_r in FTPDirectoryDocument
        https://bugs.webkit.org/show_bug.cgi?id=34409

        Platform guards for localtime_r are not needed because we already have
        WTF::getLocalTime which does the same thing.

        * loader/FTPDirectoryDocument.cpp:
        (WebCore::processFileDateString):
        * loader/FTPDirectoryParser.cpp:
        (WebCore::gmtimeQt):

git-svn-id: svn://svn.chromium.org/blink/trunk@54256 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 2a4297b7
2010-02-02 Kwang Yul Seo <skyul@company100.net>
Reviewed by Eric Seidel.
Use WTF::getLocalTime instead of localtime_r in FTPDirectoryDocument
https://bugs.webkit.org/show_bug.cgi?id=34409
Platform guards for localtime_r are not needed because we already have
WTF::getLocalTime which does the same thing.
* loader/FTPDirectoryDocument.cpp:
(WebCore::processFileDateString):
* loader/FTPDirectoryParser.cpp:
(WebCore::gmtimeQt):
2010-02-02 Adam Roben <aroben@apple.com>
Copy WebCore's bindings generation scripts to the PrivateHeaders
......
......@@ -38,14 +38,9 @@
#include "Settings.h"
#include "SharedBuffer.h"
#include "Text.h"
#include <wtf/StdLibExtras.h>
#if PLATFORM(QT)
#include <QDateTime>
// On Windows, use the threadsafe *_r functions provided by pthread.
#elif OS(WINDOWS) && (USE(PTHREADS) || HAVE(PTHREAD_H))
#include <pthread.h>
#endif
#include <wtf/CurrentTime.h>
#include <wtf/StdLibExtras.h>
using namespace std;
......@@ -200,48 +195,6 @@ static bool wasLastDayOfMonth(int year, int month, int day)
return lastDays[month] == day;
}
#if PLATFORM(QT)
/*!
Replacement for localtime_r() which is not available on MinGW.
We use this on all of Qt's platforms for portability.
*/
struct tm gmtimeQt(const QDateTime &input)
{
tm result;
const QDate date(input.date());
result.tm_year = date.year() - 1900;
result.tm_mon = date.month();
result.tm_mday = date.day();
result.tm_wday = date.dayOfWeek();
result.tm_yday = date.dayOfYear();
const QTime time(input.time());
result.tm_sec = time.second();
result.tm_min = time.minute();
result.tm_hour = time.hour();
return result;
}
static struct tm *localTimeQt(const time_t *const timep, struct tm *result)
{
const QDateTime dt(QDateTime::fromTime_t(*timep));
*result = WebCore::gmtimeQt(dt.toLocalTime());
return result;
}
#define localtime_r(x, y) localTimeQt(x, y)
#elif OS(WINDOWS) && !defined(localtime_r)
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
#define localtime_r(x, y) localtime_s((y), (x))
#else /* !_MSC_VER */
#define localtime_r(x,y) (localtime(x)?(*(y)=*localtime(x),(y)):0)
#endif
#endif
static String processFileDateString(const FTPTime& fileTime)
{
// FIXME: Need to localize this string?
......@@ -267,7 +220,7 @@ static String processFileDateString(const FTPTime& fileTime)
// If it was today or yesterday, lets just do that - but we have to compare to the current time
struct tm now;
time_t now_t = time(NULL);
localtime_r(&now_t, &now);
getLocalTime(&now_t, &now);
// localtime does "year = current year - 1900", compensate for that for readability and comparison purposes
now.tm_year += 1900;
......
......@@ -38,8 +38,27 @@ using namespace WTF;
namespace WebCore {
#if PLATFORM(QT) && defined(Q_WS_WIN32)
// Defined in FTPDirectoryDocument.cpp.
struct tm gmtimeQt(const QDateTime &input);
// Replacement for gmtime_r() which is not available on MinGW.
// We use this on Win32 Qt platform for portability.
struct tm gmtimeQt(const QDateTime& input)
{
tm result;
QDate date(input.date());
result.tm_year = date.year() - 1900;
result.tm_mon = date.month();
result.tm_mday = date.day();
result.tm_wday = date.dayOfWeek();
result.tm_yday = date.dayOfYear();
QTime time(input.time());
result.tm_sec = time.second();
result.tm_min = time.minute();
result.tm_hour = time.hour();
return result;
}
static struct tm *gmtimeQt(const time_t *const timep, struct tm *result)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment