StelUtils.cpp   StelUtils.cpp 
skipping to change at line 30 skipping to change at line 30
#include <config.h> #include <config.h>
#include <cmath> // std::fmod #include <cmath> // std::fmod
#ifdef CYGWIN #ifdef CYGWIN
#include <malloc.h> #include <malloc.h>
#endif #endif
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "VecMath.hpp" #include "VecMath.hpp"
#include "GLee.h" #include <QtOpenGL>
#include "fixx11h.h"
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QTextStream> #include <QTextStream>
#include <QFile> #include <QFile>
#include <QDebug> #include <QDebug>
#include <QLocale> #include <QLocale>
#include <QRegExp> #include <QRegExp>
namespace StelUtils namespace StelUtils
{ {
//! Return the full name of stellarium, i.e. "stellarium 0.9.0"
QString getApplicationName()
{
#ifdef SVN_REVISION
return QString("Stellarium")+" "+PACKAGE_VERSION+" (SVN r"+SVN_REVIS
ION+")";
#else
return QString("Stellarium")+" "+PACKAGE_VERSION;
#endif
}
//! Return the version of stellarium, i.e. "0.9.0"
QString getApplicationVersion()
{
#ifdef SVN_REVISION
return QString(PACKAGE_VERSION)+" (SVN r"+SVN_REVISION+")";
#else
return QString(PACKAGE_VERSION);
#endif
}
double hmsToRad(unsigned int h, unsigned int m, double s ) double hmsToRad(unsigned int h, unsigned int m, double s )
{ {
return (double)M_PI/24.*h*2.+(double)M_PI/12.*m/60.+s*M_PI/43200.; return (double)M_PI/24.*h*2.+(double)M_PI/12.*m/60.+s*M_PI/43200.;
} }
double dmsToRad(int d, unsigned int m, double s) double dmsToRad(int d, unsigned int m, double s)
{ {
if (d>=0) if (d>=0)
return (double)M_PI/180.*d+(double)M_PI/10800.*m+s*M_PI/6480 00.; return (double)M_PI/180.*d+(double)M_PI/10800.*m+s*M_PI/6480 00.;
skipping to change at line 461 skipping to change at line 478
*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;
} }
QString sixIntsToIsoString( int year, int month, int day, int hour, int min ute, int second ) QString sixIntsToIsoString( int year, int month, int day, int hour, int min ute, int second )
{ {
// formatting a negative doesnt work the way i expect // formatting a negative doesnt work the way i expect
QString dt = QString("%1-%2-%3T%4:%5:%6") QString dt = QString("%1-%2-%3T%4:%5:%6")
.arg((year >= 0 ? year : -1* year),4,10,QLatin1Char('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 (year < 0) if (year < 0)
{ {
dt.prepend("-"); dt.prepend("-");
} }
return dt; return dt;
} }
QString jdToIsoString(double jd) QString jdToIsoString(double jd)
{ {
skipping to change at line 518 skipping to change at line 535
else else
{ {
quotestartedat = i; quotestartedat = i;
} }
} }
else if (quotestartedat > 0) else if (quotestartedat > 0)
{ {
out += fmt.at(i); out += fmt.at(i);
} }
else if (fmt.at(i) == QLatin1Char('d') || else if (fmt.at(i) == QLatin1Char('d') ||
fmt.at(i) == QLatin1Char('M') || fmt.at(i) == QLatin1Char('M') ||
fmt.at(i) == QLatin1Char('y')) fmt.at(i) == QLatin1Char('y'))
{ {
int j = i+1; int j = i+1;
while ((j < fmt.length()) && (fmt.at(j) == fmt.at(i) ) && (4 >= (j-i+1))) while ((j < fmt.length()) && (fmt.at(j) == fmt.at(i) ) && (4 >= (j-i+1)))
{ {
j++; j++;
} }
QString frag = fmt.mid(i,(j-i)); QString frag = fmt.mid(i,(j-i));
if (frag == "d") if (frag == "d")
skipping to change at line 646 skipping to change at line 663
return QTime::fromString(QString("%1.%2").arg(hours).arg(mins), "h.m "); return QTime::fromString(QString("%1.%2").arg(hours).arg(mins), "h.m ");
} }
// Use Qt's own sense of time and offset instead of platform specific code. // Use Qt's own sense of time and offset instead of platform specific code.
float getGMTShiftFromQT(double JD) float getGMTShiftFromQT(double JD)
{ {
int year, month, day, hour, minute, second; int year, month, day, hour, minute, second;
getDateFromJulianDay(JD, &year, &month, &day); getDateFromJulianDay(JD, &year, &month, &day);
getTimeFromJulianDay(JD, &hour, &minute, &second); getTimeFromJulianDay(JD, &hour, &minute, &second);
// as analogous to second statement in getJDFromDate, nkerr // as analogous to second statement in getJDFromDate, nkerr
if ( year <= 0 ) { if ( year <= 0 )
year = year - 1; {
year = year - 1;
} }
QDateTime current(QDate(year, month, day), QTime(hour, minute, secon d)); QDateTime current(QDate(year, month, day), QTime(hour, minute, secon d));
if (! current.isValid()) if (! current.isValid())
{ {
//qWarning() << "JD " << QString("%1").arg(JD) << " out of b ounds of QT help with GMT shift, using current datetime"; //qWarning() << "JD " << QString("%1").arg(JD) << " out of b ounds of QT help with GMT shift, using current datetime";
// Assumes the GMT shift was always the same before year -47 10 // Assumes the GMT shift was always the same before year -47 10
current = QDateTime(QDate(-4710, month, day), QTime(hour, mi nute, second)); current = QDateTime(QDate(-4710, month, day), QTime(hour, mi nute, second));
} }
QDateTime c1 = QDateTime::fromString(current.toString(Qt::ISODate),Q
t::ISODate);
QDateTime u1 = QDateTime::fromString(current.toUTC().toString(Qt::IS
ODate),Qt::ISODate);
int secsto = u1.secsTo(c1); //Both timezones should be set to UTC because secsTo() converts both
float hrsto = secsto / 3600.0f; //times to UTC if their zones have different daylight saving time ru
return hrsto; les.
QDateTime local = current; local.setTimeSpec(Qt::UTC);
QDateTime universal = current.toUTC();
int shiftInSeconds = universal.secsTo(local);
float shiftInHours = shiftInSeconds / 3600.0f;
return shiftInHours;
} }
// UTC ! // UTC !
bool getJDFromDate(double* newjd, int y, int m, int d, int h, int min, int s) bool getJDFromDate(double* newjd, int y, int m, int d, int h, int min, int s)
{ {
double deltaTime = (h / 24.0) + (min / (24.0*60.0)) + (s / (24.0 * 6 0.0 * 60.0)) - 0.5; double deltaTime = (h / 24.0) + (min / (24.0*60.0)) + (s / (24.0 * 6 0.0 * 60.0)) - 0.5;
QDate test((y <= 0 ? y-1 : y), m, d); QDate test((y <= 0 ? y-1 : y), m, d);
// if QDate will oblige, do so. // if QDate will oblige, do so.
if ( test.isValid() ) if ( test.isValid() )
{ {
 End of changes. 7 change blocks. 
21 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/