3
3
* Copyright (C) 2002 Fabien Chereau
5
5
* This program is free software; you can redistribute it and/or
6
6
* modify it under the terms of the GNU General Public License
7
7
* as published by the Free Software Foundation; either version 2
8
8
* of the License, or (at your option) any later version.
10
10
* This program is distributed in the hope that it will be useful,
11
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
13
* GNU General Public License for more details.
15
15
* You should have received a copy of the GNU General Public License
16
16
* along with this program; if not, write to the Free Software
17
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
41
39
namespace StelUtils
41
//! Return the full name of stellarium, i.e. "stellarium 0.9.0"
42
QString getApplicationName()
45
return QString("Stellarium")+" "+PACKAGE_VERSION+" (SVN r"+SVN_REVISION+")";
47
return QString("Stellarium")+" "+PACKAGE_VERSION;
51
//! Return the version of stellarium, i.e. "0.9.0"
52
QString getApplicationVersion()
55
return QString(PACKAGE_VERSION)+" (SVN r"+SVN_REVISION+")";
57
return QString(PACKAGE_VERSION);
44
61
double hmsToRad(unsigned int h, unsigned int m, double s )
161
if (h==24 && m==0 && s==0)
178
if (h==24 && m==0 && s==0)
164
181
return QString("%1h%2m%3s").arg(h, width).arg(m).arg(s, 0, 'f', precision);
181
198
StelUtils::radToDms(angle+0.005*M_PI/180/(60*60)*(angle<0?-1.:1.), sign, d, m, s);
183
200
QTextStream os(&str);
185
202
os << (sign?'+':'-') << d << degsign;
186
203
if (std::fabs(s*100-(int)s*100)>=1)
229
246
os << qSetRealNumberPrecision(0);
233
os << qSetFieldWidth(width) << m << qSetFieldWidth(0) << '\''
234
<< fixed << qSetFieldWidth(width) << qSetPadChar('0') << s
250
os << qSetFieldWidth(width) << m << qSetFieldWidth(0) << '\''
251
<< fixed << qSetFieldWidth(width) << qSetPadChar('0') << s
235
252
<< qSetFieldWidth(0) << '\"';
459
476
// formatting a negative doesnt work the way i expect
461
478
QString dt = QString("%1-%2-%3T%4:%5:%6")
462
.arg((year >= 0 ? year : -1* year),4,10,QLatin1Char('0'))
463
.arg(month,2,10,QLatin1Char('0'))
464
.arg(day,2,10,QLatin1Char('0'))
465
.arg(hour,2,10,QLatin1Char('0'))
466
.arg(minute,2,10,QLatin1Char('0'))
467
.arg(second,2,10,QLatin1Char('0'));
479
.arg((year >= 0 ? year : -1* year),4,10,QLatin1Char('0'))
480
.arg(month,2,10,QLatin1Char('0'))
481
.arg(day,2,10,QLatin1Char('0'))
482
.arg(hour,2,10,QLatin1Char('0'))
483
.arg(minute,2,10,QLatin1Char('0'))
484
.arg(second,2,10,QLatin1Char('0'));
516
533
out += fmt.at(i);
518
535
else if (fmt.at(i) == QLatin1Char('d') ||
519
fmt.at(i) == QLatin1Char('M') ||
520
fmt.at(i) == QLatin1Char('y'))
536
fmt.at(i) == QLatin1Char('M') ||
537
fmt.at(i) == QLatin1Char('y'))
523
540
while ((j < fmt.length()) && (fmt.at(j) == fmt.at(i)) && (4 >= (j-i+1)))
646
663
getDateFromJulianDay(JD, &year, &month, &day);
647
664
getTimeFromJulianDay(JD, &hour, &minute, &second);
648
665
// as analogous to second statement in getJDFromDate, nkerr
652
670
QDateTime current(QDate(year, month, day), QTime(hour, minute, second));
653
671
if (! current.isValid())
656
674
// Assumes the GMT shift was always the same before year -4710
657
675
current = QDateTime(QDate(-4710, month, day), QTime(hour, minute, second));
659
QDateTime c1 = QDateTime::fromString(current.toString(Qt::ISODate),Qt::ISODate);
660
QDateTime u1 = QDateTime::fromString(current.toUTC().toString(Qt::ISODate),Qt::ISODate);
662
int secsto = u1.secsTo(c1);
663
float hrsto = secsto / 3600.0f;
678
//Both timezones should be set to UTC because secsTo() converts both
679
//times to UTC if their zones have different daylight saving time rules.
680
QDateTime local = current; local.setTimeSpec(Qt::UTC);
681
QDateTime universal = current.toUTC();
683
int shiftInSeconds = universal.secsTo(local);
684
float shiftInHours = shiftInSeconds / 3600.0f;