Unverified Commit ab256937 authored by Makayla Shepherd's avatar Makayla Shepherd Committed by GitHub
Browse files

Merge pull request #186 from SgStapleton/zTime

Removed Z from end of StartTime on re-ingested cubes
parents b2f401be 3b891e85
Loading
Loading
Loading
Loading
+3 −13
Original line number Diff line number Diff line
@@ -49,27 +49,17 @@ namespace Isis {
  /**
   * Constructs a iTime object and initializes it to the time from the argument.  
   *  
   * This constructor will (temporarily) strip the Z off of the end of an input UTC-formatted time 
   * if it is present. This time format is used by PDS4, but not presently supported by NAIF calls, 
   * in particular str2et_c, which is used by this class.  
   *  
   * @param time A time string formatted in standard UTC or similar format.
   *             Example:"2000/12/31 23:59:01.6789" or "2000-12-31T23:59:01.6789" or
   *             "2000-12-31T23:59:01.6789Z"
   *             Example:"2000/12/31 23:59:01.6789" or "2000-12-31T23:59:01.6789"
   */
  iTime::iTime(const QString &time) {
    LoadLeapSecondKernel();

    QString tempTime = time; 
    if (QString::compare(time.at(time.size() - 1), "Z", Qt::CaseInsensitive) == 0) {
      tempTime = time.left(time.size() - 1);
    }

    NaifStatus::CheckErrors();

    // Convert the time string to a double ephemeris time
    SpiceDouble et;
    str2et_c(tempTime.toLatin1().data(), &et);
    str2et_c(time.toLatin1().data(), &et);

    p_et = et;
    NaifStatus::CheckErrors();
+0 −2
Original line number Diff line number Diff line
@@ -72,8 +72,6 @@ namespace Isis {
   *           were signaled. References #2248.
   *  @history 2018-03-15 Adam Goins - Removed deprecated function iTime::UnloadLeapSecondKernel().
   *                          Fixes #5325.
   *  @history 2018-05-11 Kristin Berry and Makayla Shepherd - Added UTC time format that ends in Z,
   *                          as this format is used by PDS4 (and the TGO CaSSIS mission.) 
   */
  class iTime {
    public:
+0 −19
Original line number Diff line number Diff line
@@ -18,25 +18,6 @@ Unit test for iTime
   Et          = 94781765.3
   UTC         = 2003-01-02T12:15:01.1234

  Test of date = 2003/01/02 12:15:01.1234Z
   Year        = 2003
   Year        = 2003
   Month       = 1
   Month       = 1
   Day         = 2
   Day         = 2
   Hour        = 12
   Hour        = 12
   Minute      = 15
   Minute      = 15
   Second      = 1.1234
   Second      = 1.1234
   Day of Year = 2
   Day of Year = 2
   Et          = 94781765.307363
   Et          = 94781765.3
   UTC         = 2003-01-02T12:15:01.1234

  Test of date = 2000-12-31T23:59:01.6789
   Year        = 2000
   Year        = 2000
+0 −29
Original line number Diff line number Diff line
@@ -42,35 +42,6 @@ int main(int argc, char *argv[]) {
  }


  try {
    cout << endl;
    cout << setprecision(9);
    QString test = "2003/01/02 12:15:01.1234Z";
    iTime *time = new iTime(test);
    cout << "  Test of date = " << test << endl;
    cout << "   Year        = " << time->YearString() << endl;
    cout << "   Year        = " << time->Year() << endl;
    cout << "   Month       = " << time->MonthString() << endl;
    cout << "   Month       = " << time->Month() << endl;
    cout << "   Day         = " << time->DayString() << endl;
    cout << "   Day         = " << time->Day() << endl;
    cout << "   Hour        = " << time->HourString() << endl;
    cout << "   Hour        = " << time->Hour() << endl;
    cout << "   Minute      = " << time->MinuteString() << endl;
    cout << "   Minute      = " << time->Minute() << endl;
    cout << "   Second      = " << time->SecondString() << endl;
    cout << "   Second      = " << time->Second() << endl;
    cout << "   Day of Year = " << time->DayOfYearString() << endl;
    cout << "   Day of Year = " << time->DayOfYear() << endl;
    cout << "   Et          = " << time->EtString() << endl;
    cout << "   Et          = " << time->Et() << endl;
    cout << "   UTC         = " << time->UTC() << endl;
  }
  catch(IException &error) {
    error.print();
  }


  double saveEt = 0.0;
  try {
    cout << endl;
+9 −3
Original line number Diff line number Diff line
@@ -215,8 +215,14 @@ void translateLabels(FileName &inputLabel, Cube *outputCube, QString instTransFi
  archiveXlater.Auto(*(outputLabel));
  subXlater.Auto(*(outputLabel));

  // Create YearDoy keyword in Archive group
  iTime stime(outputLabel->findGroup("Instrument", Pvl::Traverse)["StartTime"][0]);
  // Remove trailing "Z" from PDS4 .xml (on re-ingestion) and create YearDoy keyword in Archive group
  PvlKeyword *startTime = &outputLabel->findGroup("Instrument", Pvl::Traverse)["StartTime"];
  QString startTimeString = startTime[0];
  if (QString::compare(startTimeString.at(startTimeString.size() - 1), "Z", Qt::CaseInsensitive) == 0){
    startTimeString = startTimeString.left(startTimeString.length() - 1);
    startTime->setValue(startTimeString);
  }
  iTime stime(startTimeString);
  
  PvlGroup &archive = outputLabel->findGroup("Archive", Pvl::Traverse);
                                                  
Loading