38
38
#include "Settings.h"
39
39
#include "SharedBuffer.h"
42
#include <wtf/CurrentTime.h>
41
43
#include <wtf/StdLibExtras.h>
45
// On Windows, use the threadsafe *_r functions provided by pthread.
46
#elif OS(WINDOWS) && (USE(PTHREADS) || HAVE(PTHREAD_H))
50
45
using namespace std;
52
47
namespace WebCore {
200
195
return lastDays[month] == day;
206
Replacement for localtime_r() which is not available on MinGW.
208
We use this on all of Qt's platforms for portability.
210
struct tm gmtimeQt(const QDateTime &input)
214
const QDate date(input.date());
215
result.tm_year = date.year() - 1900;
216
result.tm_mon = date.month();
217
result.tm_mday = date.day();
218
result.tm_wday = date.dayOfWeek();
219
result.tm_yday = date.dayOfYear();
221
const QTime time(input.time());
222
result.tm_sec = time.second();
223
result.tm_min = time.minute();
224
result.tm_hour = time.hour();
229
static struct tm *localTimeQt(const time_t *const timep, struct tm *result)
231
const QDateTime dt(QDateTime::fromTime_t(*timep));
232
*result = WebCore::gmtimeQt(dt.toLocalTime());
236
#define localtime_r(x, y) localTimeQt(x, y)
237
#elif OS(WINDOWS) && !defined(localtime_r)
238
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
239
#define localtime_r(x, y) localtime_s((y), (x))
240
#else /* !_MSC_VER */
241
#define localtime_r(x,y) (localtime(x)?(*(y)=*localtime(x),(y)):0)
245
198
static String processFileDateString(const FTPTime& fileTime)
247
200
// FIXME: Need to localize this string?
267
220
// If it was today or yesterday, lets just do that - but we have to compare to the current time
269
222
time_t now_t = time(NULL);
270
localtime_r(&now_t, &now);
223
getLocalTime(&now_t, &now);
272
225
// localtime does "year = current year - 1900", compensate for that for readability and comparison purposes
273
226
now.tm_year += 1900;