summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/wtf/DateMath.h
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-05 14:36:32 +0100
committerBen Murdoch <benm@google.com>2011-05-10 15:38:30 +0100
commitf05b935882198ccf7d81675736e3aeb089c5113a (patch)
tree4ea0ca838d9ef1b15cf17ddb3928efb427c7e5a1 /JavaScriptCore/wtf/DateMath.h
parent60fbdcc62bced8db2cb1fd233cc4d1e4ea17db1b (diff)
downloadexternal_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.zip
external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.tar.gz
external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.tar.bz2
Merge WebKit at r74534: Initial merge by git.
Change-Id: I6ccd1154fa1b19c2ec2a66878eb675738735f1eb
Diffstat (limited to 'JavaScriptCore/wtf/DateMath.h')
-rw-r--r--JavaScriptCore/wtf/DateMath.h34
1 files changed, 20 insertions, 14 deletions
diff --git a/JavaScriptCore/wtf/DateMath.h b/JavaScriptCore/wtf/DateMath.h
index be51947..8d0d932 100644
--- a/JavaScriptCore/wtf/DateMath.h
+++ b/JavaScriptCore/wtf/DateMath.h
@@ -2,6 +2,7 @@
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2010 Research In Motion Limited. All rights reserved.
*
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@@ -47,6 +48,8 @@
#include <time.h>
#include <wtf/CurrentTime.h>
#include <wtf/Noncopyable.h>
+#include <wtf/OwnArrayPtr.h>
+#include <wtf/PassOwnArrayPtr.h>
#include <wtf/UnusedParam.h>
namespace WTF {
@@ -84,18 +87,26 @@ int dayInYear(double ms, int year);
int monthFromDayInYear(int dayInYear, bool leapYear);
int dayInMonthFromDayInYear(int dayInYear, bool leapYear);
+// Returns offset milliseconds for UTC and DST.
+int32_t calculateUTCOffset();
+double calculateDSTOffset(double ms, double utcOffset);
+
} // namespace WTF
+using WTF::adoptArrayPtr;
using WTF::dateToDaysFrom1970;
using WTF::dayInMonthFromDayInYear;
using WTF::dayInYear;
using WTF::minutesPerHour;
using WTF::monthFromDayInYear;
using WTF::msPerDay;
+using WTF::msPerMinute;
using WTF::msPerSecond;
using WTF::msToYear;
using WTF::secondsPerMinute;
using WTF::parseDateFromNullTerminatedCharacters;
+using WTF::calculateUTCOffset;
+using WTF::calculateDSTOffset;
#if USE(JSC)
namespace JSC {
@@ -125,11 +136,6 @@ struct GregorianDateTime : Noncopyable {
{
}
- ~GregorianDateTime()
- {
- delete [] timeZone;
- }
-
GregorianDateTime(ExecState* exec, const tm& inTm)
: second(inTm.tm_sec)
, minute(inTm.tm_min)
@@ -150,10 +156,10 @@ struct GregorianDateTime : Noncopyable {
#if HAVE(TM_ZONE)
int inZoneSize = strlen(inTm.tm_zone) + 1;
- timeZone = new char[inZoneSize];
- strncpy(timeZone, inTm.tm_zone, inZoneSize);
+ timeZone = adoptArrayPtr(new char[inZoneSize]);
+ strncpy(timeZone.get(), inTm.tm_zone, inZoneSize);
#else
- timeZone = 0;
+ timeZone = nullptr;
#endif
}
@@ -176,7 +182,7 @@ struct GregorianDateTime : Noncopyable {
ret.tm_gmtoff = static_cast<long>(utcOffset);
#endif
#if HAVE(TM_ZONE)
- ret.tm_zone = timeZone;
+ ret.tm_zone = timeZone.get();
#endif
return ret;
@@ -195,11 +201,11 @@ struct GregorianDateTime : Noncopyable {
isDST = rhs.isDST;
utcOffset = rhs.utcOffset;
if (rhs.timeZone) {
- int inZoneSize = strlen(rhs.timeZone) + 1;
- timeZone = new char[inZoneSize];
- strncpy(timeZone, rhs.timeZone, inZoneSize);
+ int inZoneSize = strlen(rhs.timeZone.get()) + 1;
+ timeZone = adoptArrayPtr(new char[inZoneSize]);
+ strncpy(timeZone.get(), rhs.timeZone.get(), inZoneSize);
} else
- timeZone = 0;
+ timeZone = nullptr;
}
int second;
@@ -212,7 +218,7 @@ struct GregorianDateTime : Noncopyable {
int year;
int isDST;
int utcOffset;
- char* timeZone;
+ OwnArrayPtr<char> timeZone;
};
static inline int gmtoffset(const GregorianDateTime& t)