12#include <QRegularExpression>
14#include "Preference.h"
19#include "SpecialPixel.h"
20#include "NaifStatus.h"
27 bool iTime::p_lpInitialized =
false;
51 str2et_c(time.toLatin1().data(), &et);
74 str2et_c(time.toLatin1().data(), &et);
168 iTime iTime::operator +(
const double &secondsToAdd)
const {
175 void iTime::operator +=(
const double &secondsToAdd) {
176 if(!IsSpecial(secondsToAdd) && !IsSpecial(
p_et))
177 p_et += secondsToAdd;
182 time += secondsToAdd;
189 iTime iTime::operator -(
const double &secondsToSubtract)
const {
191 tmp -= secondsToSubtract;
196 double iTime::operator -(
const iTime &iTimeToSubtract)
const {
197 return p_et - iTimeToSubtract.p_et;
201 void iTime::operator -=(
const double &secondsToSubtract) {
202 if (!IsSpecial(secondsToSubtract) && !IsSpecial(
p_et))
203 p_et -= secondsToSubtract;
208 time -= secondsToSubtract;
236 timout_c(
p_et,
"YYYY", 5, out);
238 return IString(out).ToInteger();
260 timout_c(
p_et,
"MM", 3, out);
262 return IString(out).ToInteger();
284 timout_c(
p_et,
"DD", 3, out);
286 return IString(out).ToInteger();
308 timout_c(
p_et,
"HR", 3, out);
310 return IString(out).ToInteger();
332 timout_c(
p_et,
"MN", 3, out);
334 return IString(out).ToInteger();
344 osec.setf(ios::fixed);
345 osec << setprecision(precision) <<
Second();
346 QString sSeconds(osec.str().c_str());
347 sSeconds = sSeconds.remove(QRegularExpression(
"(\\.0*|0*)$"));
349 if(sSeconds.isEmpty()) sSeconds =
"0";
363 timout_c(
p_et,
"SC.#######::RND", 256, out);
365 return IString(out).ToDouble();
387 timout_c(
p_et,
"DOY", 4, out);
389 return IString(out).ToInteger();
427 void iTime::setEt(
double et) {
434 void iTime::setUtc(QString utcString) {
436 if ( utcString.contains(
"T") &&
437 !utcString.contains(
"-") &&
438 !utcString.contains(
":")) {
439 QString dateString = utcString.split(
"T").front();
440 dateString.insert(4,
"-");
443 if (dateString.size() > 8) {
444 dateString.insert(7,
"-");
447 QString timeString = utcString.split(
"T").back();
449 if (timeString.size() < 6) {
450 timeString.resize(6,
'0');
452 timeString.insert(2,
":");
453 timeString.insert(5,
":");
455 utcString = dateString +
"T" + timeString;
462 utc2et_c(utcString.toLatin1().data(), &et);
476 if(p_lpInitialized)
return;
479 Isis::PvlGroup &dataDir = Isis::Preference::Preferences().findGroup(
"DataDirectory");
480 QString baseDir = dataDir[
"Base"];
481 baseDir +=
"/kernels/lsk/";
482 FileName leapSecond(baseDir +
"naif????.tls");
483 QString leapSecondName;
485 leapSecondName = QString(leapSecond.highestVersion().expanded());
487 catch (IException &e) {
488 QString msg =
"Unable to load leadsecond file. Either the data area is not set or there are no naif####.tls files present";
489 throw IException(e, IException::User, msg, _FILEINFO_);
493 SpiceQL::load(leapSecondName.toLatin1().data());
496 p_lpInitialized =
true;
507 time_t startTime = time(NULL);
508 struct tm *tmbuf = gmtime(&startTime);
510 strftime(timestr, 80,
"%Y-%m-%dT%H:%M:%S", tmbuf);
511 return (QString) timestr;
523 time_t startTime = time(NULL);
524 struct tm *tmbuf = localtime(&startTime);
526 strftime(timestr, 80,
"%Y-%m-%dT%H:%M:%S", tmbuf);
527 return (QString) timestr;
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Parse and return pieces of a time string.
QString HourString() const
Returns the hour portion of the time as a string.
bool operator>=(const iTime &time)
Compare two iTime objects for greater than or equal.
int Hour() const
Returns the hour portion of the time as an int.
QString DayOfYearString() const
Returns the day of year portion of the time as a string.
double Second() const
Returns the second portion of the time as a double.
bool operator!=(const iTime &time)
Compare two iTime objects for inequality.
QString EtString() const
Returns the ephemeris time (TDB) representation of the time as a string.
static QString CurrentLocalTime()
Returns the current local time This time is taken directly from the system clock, so if the system cl...
void operator=(const QString &time)
Changes the value of the iTime object.
QString DayString() const
Returns the dat portion of the time as a string.
int Day() const
Returns the day portion of the time as an int.
QString SecondString(int precision=8) const
Returns the second portion of the time as a string.
bool operator>(const iTime &time)
Compare two iTime objects for greater than.
QString MonthString() const
Returns the month portion of the time as a string.
QString MinuteString() const
Returns the minute portion of the time as a string.
bool operator<(const iTime &time)
Compare two iTime objects for less than.
int Month() const
Returns the month portion of the time as an int.
static QString CurrentGMT()
Returns the current Greenwich Mean iTime The time is based on the system time, so it is only as accur...
int Minute() const
Returns the minute portion of the time as an int.
int DayOfYear() const
Returns the day of year portion of the time as an int.
QString YearString() const
Returns the year portion of the time as a string.
QString UTC(int precision=8) const
Returns the internally stored time, formatted as a UTC time.
bool operator<=(const iTime &time)
Compare two iTime objects for less than or equal.
double p_et
The ephemeris representaion of the original string passed into the constructor or the operator= membe...
void LoadLeapSecondKernel()
Uses the Naif routines to load the most current leap second kernel.
int Year() const
Returns the year portion of the time as an int.
iTime()
Constructs an empty iTime object.
bool operator==(const iTime &time)
Compare two iTime objects for equality.
This is free and unencumbered software released into the public domain.
QString toString(const LinearAlgebra::Vector &vector, int precision)
A global function to format LinearAlgebra::Vector as a QString with the given precision.
Coordinate operator+(const Coordinate &A, const Coordinate &B)
Summation operator for Coordinate.
Coordinate operator-(const Coordinate &A, const Coordinate &B)
Subtraction operator for Coordinate.
Namespace for the standard library.