diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2010-04-20 15:13:59 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@accenture.com> | 2010-04-20 15:13:59 (GMT) |
commit | 3e05df4abe1469fb4fb04e6d26f2befb3317346e (patch) | |
tree | bb5d7eddbe3c47528f77de87b2ebef482b7859a9 /src/corelib | |
parent | 2d88a85bd6e1b03e87ff5e8c67bbef5d4a439d06 (diff) | |
download | Qt-3e05df4abe1469fb4fb04e6d26f2befb3317346e.zip Qt-3e05df4abe1469fb4fb04e6d26f2befb3317346e.tar.gz Qt-3e05df4abe1469fb4fb04e6d26f2befb3317346e.tar.bz2 |
Use a compile time constant for the C epoch as a julian day.
The julian day calculation is complex, so capturing the value and storing
as a compile time constant will save some calculations at runtime.
Reviewed-by: Thiago Macieira
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qdatetime.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 36e5173..c753c0b 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -88,7 +88,8 @@ enum { SECS_PER_HOUR = 3600, MSECS_PER_HOUR = 3600000, SECS_PER_MIN = 60, - MSECS_PER_MIN = 60000 + MSECS_PER_MIN = 60000, + JULIAN_DAY_FOR_EPOCH = 2440588 // result of julianDayFromGregorianDate(1970, 1, 1) }; static inline QDate fixedDate(int y, int m, int d) @@ -2320,8 +2321,8 @@ void QDateTime::setTimeSpec(Qt::TimeSpec spec) qint64 toMSecsSinceEpoch_helper(qint64 jd, int msecs) { - int days = jd - julianDayFromGregorianDate(1970, 1, 1); - qint64 retval = (qlonglong(days) * MSECS_PER_DAY) + msecs; + qint64 days = jd - JULIAN_DAY_FOR_EPOCH; + qint64 retval = (days * MSECS_PER_DAY) + msecs; return retval; } |