StelLocaleMgr.cpp   StelLocaleMgr.cpp 
skipping to change at line 20 skipping to change at line 20
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include <config.h>
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include <QLocale> #include <QLocale>
#include <QDebug> #include <QDebug>
#include <QSettings> #include <QSettings>
#include <QString> #include <QString>
#include <QTextStream> #include <QTextStream>
skipping to change at line 173 skipping to change at line 172
{ {
double shift = 0.0; double shift = 0.0;
if (timeZoneMode == STzGMTShift) if (timeZoneMode == STzGMTShift)
{ {
shift = GMTShift; shift = GMTShift;
} }
else else
{ {
shift = StelUtils::getGMTShiftFromQT(JD)*0.041666666666; shift = StelUtils::getGMTShiftFromQT(JD)*0.041666666666;
} }
return StelUtils::jdToIsoString(JD + shift); return StelUtils::julianDayToISO8601String(JD + shift);
} }
//! get the six ints from an ISO8601 date time, understood to be local time , make a jdate out //! get the six ints from an ISO8601 date time, understood to be local time , make a jdate out
//! of them. //! of them.
double StelLocaleMgr::getJdFromISO8601TimeLocal(const QString& t) const double StelLocaleMgr::getJdFromISO8601TimeLocal(const QString& t, bool* ok) const
{ {
QList<int> numbers = StelUtils::getIntsFromISO8601String(t); double jd = StelUtils::getJulianDayFromISO8601String(t, ok);
if (numbers.size() == 6) if (!*ok)
{ {
int y = numbers[0]; qWarning() << "StelLocaleMgr::getJdFromISO8601TimeLocal: inv
int m = numbers[1]; alid ISO8601 date. Returning JD=0";
int d = numbers[2];
int h = numbers[3];
int mn = numbers[4];
int s = numbers[5];
double jd;
if ( ! StelUtils::getJDFromDate(&jd, y, m, d, h, mn, s) )
{
qWarning() << "StelLocaleMgr::getJdFromISO8601TimeLo
cal: StelUtils::getJDFromDate failed! returning beginning of epoch!";
return 0.0;
}
// modified by shift
if (timeZoneMode == STzGMTShift)
jd -= GMTShift;
else
jd -= StelUtils::getGMTShiftFromQT(jd)*0.04166666666
6;
return jd;
}
else
{
qWarning() << "StelLocaleMgr::getJdFromISO8601TimeLocal: did
not get 6 ints back from TextEntryDateTimeValidator for input " << t << ",
returning beginning of epoch!";
return 0.0; return 0.0;
} }
// modified by shift
if (timeZoneMode == STzGMTShift)
jd -= GMTShift;
else
jd -= StelUtils::getGMTShiftFromQT(jd)*0.041666666666;
return jd;
} }
// Return a string with the local date formated according to the dateFormat variable // Return a string with the local date formated according to the dateFormat variable
QString StelLocaleMgr::getPrintableDateLocal(double JD) const QString StelLocaleMgr::getPrintableDateLocal(double JD) const
{ {
int year, month, day, dayOfWeek; int year, month, day, dayOfWeek;
double shift = 0.0; double shift = 0.0;
if (timeZoneMode == STzGMTShift) if (timeZoneMode == STzGMTShift)
{ {
shift = GMTShift; shift = GMTShift;
skipping to change at line 345 skipping to change at line 326
float StelLocaleMgr::getGMTShift(double JD) const float StelLocaleMgr::getGMTShift(double JD) const
{ {
if (timeZoneMode == STzGMTShift) return GMTShift; if (timeZoneMode == STzGMTShift) return GMTShift;
else return StelUtils::getGMTShiftFromQT(JD); else return StelUtils::getGMTShiftFromQT(JD);
} }
// Convert a 2 letter country code to string // Convert a 2 letter country code to string
QString StelLocaleMgr::countryCodeToString(const QString& countryCode) QString StelLocaleMgr::countryCodeToString(const QString& countryCode)
{ {
QMap<QString, QString>::ConstIterator i = countryCodeToStringMap.fin d(countryCode); QMap<QString, QString>::ConstIterator i = countryCodeToStringMap.fin d(countryCode);
return (i!=countryCodeToStringMap.end()) ? i.value() : QString(); return (i!=countryCodeToStringMap.constEnd()) ? i.value() : QString( );
} }
// Return a list of all the known country names // Return a list of all the known country names
QStringList StelLocaleMgr::getAllCountryNames() QStringList StelLocaleMgr::getAllCountryNames()
{ {
QStringList res; QStringList res;
for (QMap<QString, QString>::ConstIterator i = countryCodeToStringMa p.begin();i!=countryCodeToStringMap.end();++i) for (QMap<QString, QString>::ConstIterator i = countryCodeToStringMa p.constBegin();i!=countryCodeToStringMap.constEnd();++i)
res.append(i.value()); res.append(i.value());
res.sort(); res.sort();
return res; return res;
} }
 End of changes. 8 change blocks. 
37 lines changed or deleted 15 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/