~ubuntu-branches/ubuntu/lucid/webkit/lucid-updates

« back to all changes in this revision

Viewing changes to WebCore/loader/FTPDirectoryDocument.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Gustavo Noronha Silva
  • Date: 2010-02-04 19:30:57 UTC
  • mfrom: (1.2.8 upstream) (4.3.9 sid)
  • Revision ID: james.westby@ubuntu.com-20100204193057-d3018lm1fipb0703
* New upstream release
* debian/copyright:
- Updated with changes since 1.1.19.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include "Settings.h"
39
39
#include "SharedBuffer.h"
40
40
#include "Text.h"
 
41
 
 
42
#include <wtf/CurrentTime.h>
41
43
#include <wtf/StdLibExtras.h>
42
44
 
43
 
#if PLATFORM(QT)
44
 
#include <QDateTime>
45
 
// On Windows, use the threadsafe *_r functions provided by pthread.
46
 
#elif OS(WINDOWS) && (USE(PTHREADS) || HAVE(PTHREAD_H))
47
 
#include <pthread.h>
48
 
#endif
49
 
 
50
45
using namespace std;
51
46
 
52
47
namespace WebCore {
200
195
    return lastDays[month] == day;
201
196
}
202
197
 
203
 
#if PLATFORM(QT)
204
 
 
205
 
/*!
206
 
 Replacement for localtime_r() which is not available on MinGW.
207
 
 
208
 
 We use this on all of Qt's platforms for portability.
209
 
 */
210
 
struct tm gmtimeQt(const QDateTime &input)
211
 
{
212
 
    tm result;
213
 
 
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();
220
 
 
221
 
    const QTime time(input.time());
222
 
    result.tm_sec = time.second();
223
 
    result.tm_min = time.minute();
224
 
    result.tm_hour = time.hour();
225
 
 
226
 
    return result;
227
 
}
228
 
 
229
 
static struct tm *localTimeQt(const time_t *const timep, struct tm *result)
230
 
{
231
 
    const QDateTime dt(QDateTime::fromTime_t(*timep));
232
 
    *result = WebCore::gmtimeQt(dt.toLocalTime());
233
 
    return result;
234
 
}
235
 
 
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)
242
 
#endif
243
 
#endif
244
 
 
245
198
static String processFileDateString(const FTPTime& fileTime)
246
199
{
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
268
221
    struct tm now;
269
222
    time_t now_t = time(NULL);
270
 
    localtime_r(&now_t, &now);
 
223
    getLocalTime(&now_t, &now);
271
224
    
272
225
    // localtime does "year = current year - 1900", compensate for that for readability and comparison purposes
273
226
    now.tm_year += 1900;