Commit 0111020c authored by Jasem Mutlaq's avatar Jasem Mutlaq

Fix TZ ambiguity. SetTZ was renamed to SetTZ0 since it sets the TimeZone...

Fix TZ ambiguity. SetTZ was renamed to SetTZ0 since it sets the TimeZone WITHOUT DST correction. INDI Mount and GPS updates now account for that. Improved debugging statements
parent 8d80f286
......@@ -130,7 +130,7 @@ class GeoLocation
/** Set Time zone.
* @param value the new time zone */
void setTZ(double value) { TimeZone = value; }
void setTZ0(double value) { TimeZone = value; }
/** Set Time zone rule.
* @param value pointer to the new time zone rule */
......
......@@ -453,7 +453,7 @@ bool LocationDialog::updateCity(CityOperation operation)
g->setCountry(country);
g->setLat(lat);
g->setLong(lng);
g->setTZ(TZ);
g->setTZ0(TZ);
g->setTZRule(&KStarsData::Instance()->Rulebook[TZrule]);
g->setElevation(height);
......
......@@ -227,11 +227,17 @@ void GenericDevice::processNumber(INumberVectorProperty *nvp)
GeoLocation *geo = KStars::Instance()->data()->geo();
if (geo->name() != i18n("GPS Location"))
QString newLocationName;
if (getDriverInterface() & INDI::BaseDevice::GPS_INTERFACE)
newLocationName = i18n("GPS Location");
else
newLocationName = i18n("Mount Location");
if (geo->name() != newLocationName)
{
double TZ = geo->TZ();
double TZ0 = geo->TZ0();
TimeZoneRule *rule = geo->tzrule();
geo = new GeoLocation(lng, lat, i18n("GPS Location"), "", "", TZ, rule, elev);
geo = new GeoLocation(lng, lat, newLocationName, "", "", TZ0, rule, elev);
}
else
{
......@@ -301,7 +307,12 @@ void GenericDevice::processText(ITextVectorProperty *tvp)
KStars::Instance()->data()->syncLST();
GeoLocation *geo = KStars::Instance()->data()->geo();
geo->setTZ(utcOffset);
if (geo->tzrule())
utcOffset -= geo->tzrule()->deltaTZ();
// TZ0 is the timezone WTIHOUT any DST offsets. Above, we take INDI UTC Offset (with DST already included)
// and subtract from it the deltaTZ from the current TZ rule.
geo->setTZ0(utcOffset);
}
emit textUpdated(tvp);
......
......@@ -16,6 +16,7 @@
***************************************************************************/
#include "kstars.h"
#include "kstars_debug.h"
#include "fov.h"
#include "kspaths.h"
......@@ -790,8 +791,10 @@ void KStars::datainitFinished()
//Show TotD
KTipDialog::showTip(this, "kstars/tips");
//DEBUG
qDebug() << "The current Date/Time is: " << KStarsDateTime::currentDateTime().toString();
// Initial State
qCDebug(KSTARS) << "Date/Time is:" << data()->clock()->utc().toString();
qCDebug(KSTARS) << "Location:" << data()->geo()->fullName();
qCDebug(KSTARS) << "TZ0:" << data()->geo()->TZ0() << "TZ:" << data()->geo()->TZ();
KSTheme::Manager::instance()->setCurrentTheme(Options::currentTheme());
}
......
......@@ -16,10 +16,10 @@
***************************************************************************/
#include "timezonerule.h"
#include "kstars_debug.h"
#include <KLocalizedString>
#include <QDebug>
#include <QString>
TimeZoneRule::TimeZoneRule()
......@@ -45,7 +45,7 @@ TimeZoneRule::TimeZoneRule(const QString &smonth, const QString &sday, const QTi
}
else
{
qWarning() << i18n("Error parsing TimeZoneRule, setting to empty rule.");
qCWarning(KSTARS) << i18n("Error parsing TimeZoneRule, setting to empty rule.");
setEmpty();
}
}
......@@ -73,12 +73,12 @@ void TimeZoneRule::setDST(bool activate)
{
if (activate)
{
qDebug() << "Daylight Saving Time active";
qCDebug(KSTARS) << "Daylight Saving Time active";
dTZ = HourOffset;
}
else
{
qDebug() << "Daylight Saving Time inactive";
qCDebug(KSTARS) << "Daylight Saving Time inactive";
dTZ = 0.0;
}
}
......@@ -112,7 +112,7 @@ int TimeZoneRule::initMonth(const QString &mn)
else if (ml == "dec")
return 12;
qWarning() << i18n("Could not parse %1 as a valid month code.", mn);
qCWarning(KSTARS) << i18n("Could not parse %1 as a valid month code.", mn);
return 0;
}
......@@ -225,7 +225,7 @@ bool TimeZoneRule::initDay(const QString &dy, int &Day, int &Week)
}
}
qWarning() << i18n("Could not parse %1 as a valid day code.", dy);
qCWarning(KSTARS) << i18n("Could not parse %1 as a valid day code.", dy);
return false;
}
......@@ -373,7 +373,7 @@ void TimeZoneRule::nextDSTChange_LTime(const KStarsDateTime &date)
result = KStarsDateTime(QDate(y, StartMonth, findStartDay(result)), StartTime);
}
qDebug() << "Next Daylight Savings Time change (Local Time): " << result.toString();
qCDebug(KSTARS) << "Next Daylight Savings Time change (Local Time): " << result.toString();
next_change_ltime = result;
}
......@@ -412,7 +412,7 @@ void TimeZoneRule::previousDSTChange_LTime(const KStarsDateTime &date)
result = KStarsDateTime(QDate(y, RevertMonth, findRevertDay(result)), RevertTime);
}
qDebug() << "Previous Daylight Savings Time change (Local Time): " << result.toString();
qCDebug(KSTARS) << "Previous Daylight Savings Time change (Local Time): " << result.toString();
next_change_ltime = result;
}
......@@ -422,7 +422,7 @@ void TimeZoneRule::nextDSTChange(const KStarsDateTime &local_date, const double
// just decrement timezone offset and hour offset
KStarsDateTime result = local_date.addSecs(int((TZoffset + deltaTZ()) * -3600));
qDebug() << "Next Daylight Savings Time change (UTC): " << result.toString();
qCDebug(KSTARS) << "Next Daylight Savings Time change (UTC): " << result.toString();
next_change_utc = result;
}
......@@ -436,7 +436,7 @@ void TimeZoneRule::previousDSTChange(const KStarsDateTime &local_date, const dou
if (result.date().month() == RevertMonth)
result = result.addSecs(int(HourOffset * -3600));
qDebug() << "Previous Daylight Savings Time change (UTC): " << result.toString();
qCDebug(KSTARS) << "Previous Daylight Savings Time change (UTC): " << result.toString();
next_change_utc = result;
}
......@@ -479,7 +479,7 @@ void TimeZoneRule::reset_with_ltime(KStarsDateTime &ltime, const double TZoffset
if (active_with_houroffset != active_normal && ValidLTime.date().month() == StartMonth)
{
// current time is the start time
qDebug() << "Current time = Starttime: invalid local time due to daylight saving time";
qCDebug(KSTARS) << "Current time = Starttime: invalid local time due to daylight saving time";
// set a correct local time because the current time doesn't exists
// if automatic DST change happend, new DST setting is the opposite of current setting
......@@ -526,7 +526,7 @@ void TimeZoneRule::reset_with_ltime(KStarsDateTime &ltime, const double TZoffset
if (active_with_houroffset != active_normal && RevertMonth == ValidLTime.date().month())
{
// current time is the revert time
qDebug() << "Current time = Reverttime";
qCDebug(KSTARS) << "Current time = Reverttime";
// we don't kneed to change the local time, because local time always exists, but
// some times exists twice, so we have to reset DST status
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment