StelUtils.cpp   StelUtils.cpp 
skipping to change at line 50 skipping to change at line 50
{ {
//! Return the full name of stellarium, i.e. "stellarium 0.9.0" //! Return the full name of stellarium, i.e. "stellarium 0.9.0"
QString getApplicationName() QString getApplicationName()
{ {
return QString("Stellarium")+" "+StelUtils::getApplicationVersion(); return QString("Stellarium")+" "+StelUtils::getApplicationVersion();
} }
//! Return the version of stellarium, i.e. "0.9.0" //! Return the version of stellarium, i.e. "0.9.0"
QString getApplicationVersion() QString getApplicationVersion()
{ {
#ifdef STELLARIUM_RELEASE_BUILD #if defined(STELLARIUM_VERSION)
return QString(PACKAGE_VERSION);
#else
#ifdef BZR_REVISION
return QString(PACKAGE_VERSION)+" (BZR r"+BZR_REVISION+")";
#elif defined(STELLARIUM_VERSION)
return QString(STELLARIUM_VERSION); return QString(STELLARIUM_VERSION);
#else #elif defined(BZR_REVISION)
return QString(PACKAGE_VERSION)+QChar(0x03B2); return QString("%1.%2 [%3]").arg(PACKAGE_VERSION).arg(BZR_REVISION).
#endif arg(BZR_BRANCH);
#else
return QString(PACKAGE_VERSION);
#endif #endif
} }
QString getOperatingSystemInfo() QString getOperatingSystemInfo()
{ {
QString OS = "Unknown operating system"; QString OS = "Unknown operating system";
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
switch(QSysInfo::WindowsVersion) switch(QSysInfo::WindowsVersion)
{ {
skipping to change at line 751 skipping to change at line 747
if (*mm > 2) if (*mm > 2)
{ {
--(*yy); --(*yy);
} }
if (julian < 0) if (julian < 0)
{ {
*yy -= 100 * (1 - julian / 36525); *yy -= 100 * (1 - julian / 36525);
} }
} }
void getTimeFromJulianDay(const double julianDay, int *hour, int *minute, i nt *second) void getTimeFromJulianDay(const double julianDay, int *hour, int *minute, i nt *second, int *millis)
{ {
double frac = julianDay - (floor(julianDay)); double frac = julianDay - (floor(julianDay));
int s = (int)floor((frac * 24.0 * 60.0 * 60.0) + 0.0001); // add co double secs = frac * 24.0 * 60.0 * 60.0 + 0.0001; // add constant to
nstant to fix floating-point truncation error fix floating-point truncation error
int s = (int)floor(secs);
*hour = ((s / (60 * 60))+12)%24; *hour = ((s / (60 * 60))+12)%24;
*minute = (s/(60))%60; *minute = (s/(60))%60;
*second = s % 60; *second = s % 60;
if(millis)
{
*millis = (int)floor((secs - floor(secs)) * 1000.0);
}
} }
QString julianDayToISO8601String(const double jd) QString julianDayToISO8601String(const double jd, bool addMS)
{ {
int year, month, day, hour, minute, second; int year, month, day, hour, minute, second,millis;
getDateFromJulianDay(jd, &year, &month, &day); getDateFromJulianDay(jd, &year, &month, &day);
getTimeFromJulianDay(jd, &hour, &minute, &second); getTimeFromJulianDay(jd, &hour, &minute, &second, addMS ? &millis : NULL );
QString res = QString("%1-%2-%3T%4:%5:%6") QString res = QString("%1-%2-%3T%4:%5:%6")
.arg((year >= 0 ? year : -1* year),4,10,QLa tin1Char('0')) .arg((year >= 0 ? year : -1* year),4,10,QLa tin1Char('0'))
.arg(month,2,10,QLatin1Char('0')) .arg(month,2,10,QLatin1Char('0'))
.arg(day,2,10,QLatin1Char('0')) .arg(day,2,10,QLatin1Char('0'))
.arg(hour,2,10,QLatin1Char('0')) .arg(hour,2,10,QLatin1Char('0'))
.arg(minute,2,10,QLatin1Char('0')) .arg(minute,2,10,QLatin1Char('0'))
.arg(second,2,10,QLatin1Char('0')); .arg(second,2,10,QLatin1Char('0'));
if(addMS)
{
res = res.append(".%1").arg(millis,3,10,QLatin1Char('0'));
}
if (year < 0) if (year < 0)
{ {
res.prepend("-"); res.prepend("-");
} }
return res; return res;
} }
// Format the date per the fmt. // Format the date per the fmt.
QString localeDateString(const int year, const int month, const int day, co nst int dayOfWeek, const QString &fmt) QString localeDateString(const int year, const int month, const int day, co nst int dayOfWeek, const QString &fmt)
{ {
skipping to change at line 2268 skipping to change at line 2274
cos_sin += 2; cos_sin += 2;
} }
return cos_sin_rho; return cos_sin_rho;
} }
double getDecYear(const int year, const int month, const int day) double getDecYear(const int year, const int month, const int day)
{ {
return year+((month-1)*30.5+day/31.*30.5)/366; return year+((month-1)*30.5+day/31.*30.5)/366;
} }
int compareVersions(const QString v1, const QString v2)
{
// result (-1: v1<v2; 0: v1==v2; 1: v1>v2)
int result = 0;
QStringList v1s = v1.split(".");
QStringList v2s = v2.split(".");
int ver1 = v1s.at(0).toInt()*1000 + v1s.at(1).toInt()*100 + v1s.at(2
).toInt();
int ver2 = v2s.at(0).toInt()*1000 + v2s.at(1).toInt()*100 + v2s.at(2
).toInt();
if (ver1<ver2)
result = -1;
else if (ver1 == ver2)
result = 0;
else if (ver1 > ver2)
result = 1;
return result;
}
//! Uncompress gzip or zlib compressed data. //! Uncompress gzip or zlib compressed data.
QByteArray uncompress(const QByteArray& data) QByteArray uncompress(const QByteArray& data)
{ {
if (data.size() <= 4) if (data.size() <= 4)
return QByteArray(); return QByteArray();
//needed for const-correctness, no deep copy performed //needed for const-correctness, no deep copy performed
QByteArray dataNonConst(data); QByteArray dataNonConst(data);
QBuffer buf(&dataNonConst); QBuffer buf(&dataNonConst);
buf.open(QIODevice::ReadOnly); buf.open(QIODevice::ReadOnly);
 End of changes. 10 change blocks. 
15 lines changed or deleted 42 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/