当前位置: 首页>>代码示例>>C++>>正文


C++ DateAndTime::toISO8601String方法代码示例

本文整理汇总了C++中DateAndTime::toISO8601String方法的典型用法代码示例。如果您正苦于以下问题:C++ DateAndTime::toISO8601String方法的具体用法?C++ DateAndTime::toISO8601String怎么用?C++ DateAndTime::toISO8601String使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateAndTime的用法示例。


在下文中一共展示了DateAndTime::toISO8601String方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: accept

void StartLiveDataDialog::accept()
{
  // Now manually set the StartTime property as there's a computation needed
  DateAndTime startTime = DateAndTime::getCurrentTime() - ui.dateTimeEdit->value()*60.0;
  m_algorithm->setPropertyValue("StartTime",startTime.toISO8601String());

  AlgorithmDialog::accept(); // accept executes the algorithm
}
开发者ID:nimgould,项目名称:mantid,代码行数:8,代码来源:StartLiveDataDialog.cpp

示例2: shiftTimeOfLogForStringProperty

/**
 * Shift the times in a log of a string property
 * @param logEntry :: the string property
 * @param timeShift :: the time shift.
 */
void ChangeTimeZero::shiftTimeOfLogForStringProperty(
    PropertyWithValue<std::string> *logEntry, double timeShift) const {
  // Parse the log entry and replace all ISO8601 strings with an adjusted value
  auto value = logEntry->value();
  if (checkForDateTime(value)) {
    DateAndTime dateTime(value);
    DateAndTime shiftedTime = dateTime + timeShift;
    logEntry->setValue(shiftedTime.toISO8601String());
  }
}
开发者ID:DiegoMonserrat,项目名称:mantid,代码行数:15,代码来源:ChangeTimeZero.cpp

示例3: saveTimeVector

 void saveTimeVector(::NeXus::File * file, TimeSeriesProperty<NumT> * prop)
 {
   std::vector<DateAndTime> times = prop->timesAsVector();
   DateAndTime start = times[0];
   std::vector<double> timeSec(times.size());
   for (size_t i=0; i<times.size(); i++)
     timeSec[i] = double(times[i].totalNanoseconds() - start.totalNanoseconds()) * 1e-9;
   file->writeData("time", timeSec);
   file->openData("time");
   file->putAttr("start", start.toISO8601String() );
   file->closeData();
 }
开发者ID:AlistairMills,项目名称:mantid,代码行数:12,代码来源:PropertyNexus.cpp

示例4: exec

/** Execute the algorithm.
 */
void LoadLiveData::exec() {
  // The full, post-processed output workspace
  m_outputWS = this->getProperty("OutputWorkspace");

  // Validate inputs
  if (this->hasPostProcessing()) {
    if (this->getPropertyValue("AccumulationWorkspace").empty())
      throw std::invalid_argument("Must specify the AccumulationWorkspace "
                                  "parameter if using PostProcessing.");

    // The accumulated but not post-processed output workspace
    m_accumWS = this->getProperty("AccumulationWorkspace");
  } else {
    // No post-processing, so the accumulation and output are the same
    m_accumWS = m_outputWS;
  }

  // Get or create the live listener
  ILiveListener_sptr listener = this->getLiveListener();

  // Do we need to reset the data?
  bool dataReset = listener->dataReset();

  // The listener returns a MatrixWorkspace containing the chunk of live data.
  Workspace_sptr chunkWS;
  bool dataNotYetGiven = true;
  while (dataNotYetGiven) {
    try {
      chunkWS = listener->extractData();
      dataNotYetGiven = false;
    } catch (Exception::NotYet &ex) {
      g_log.warning() << "The " << listener->name()
                      << " is not ready to return data: " << ex.what() << "\n";
      g_log.warning()
          << "Trying again in 10 seconds - cancel the algorithm to stop.\n";
      const int tenSeconds = 40;
      for (int i = 0; i < tenSeconds; ++i) {
        Poco::Thread::sleep(10000 / tenSeconds); // 250 ms
        this->interruption_point();
      }
    }
  }

  // TODO: Have the ILiveListener tell me exactly the time stamp
  DateAndTime lastTimeStamp = DateAndTime::getCurrentTime();
  this->setPropertyValue("LastTimeStamp", lastTimeStamp.toISO8601String());

  // Now we process the chunk
  Workspace_sptr processed = this->processChunk(chunkWS);

  bool PreserveEvents = this->getProperty("PreserveEvents");
  EventWorkspace_sptr processedEvent =
      boost::dynamic_pointer_cast<EventWorkspace>(processed);
  if (!PreserveEvents && processedEvent) {
    // Convert the monitor workspace, if there is one and it's necessary
    MatrixWorkspace_sptr monitorWS = processedEvent->monitorWorkspace();
    auto monitorEventWS =
        boost::dynamic_pointer_cast<EventWorkspace>(monitorWS);
    if (monitorEventWS) {
      auto monAlg = this->createChildAlgorithm("ConvertToMatrixWorkspace");
      monAlg->setProperty("InputWorkspace", monitorEventWS);
      monAlg->executeAsChildAlg();
      if (!monAlg->isExecuted())
        g_log.error(
            "Failed to convert monitors from events to histogram form.");
      monitorWS = monAlg->getProperty("OutputWorkspace");
    }

    // Now do the main workspace
    Algorithm_sptr alg = this->createChildAlgorithm("ConvertToMatrixWorkspace");
    alg->setProperty("InputWorkspace", processedEvent);
    std::string outputName = "__anonymous_livedata_convert_" +
                             this->getPropertyValue("OutputWorkspace");
    alg->setPropertyValue("OutputWorkspace", outputName);
    alg->execute();
    if (!alg->isExecuted())
      throw std::runtime_error("Error when calling ConvertToMatrixWorkspace "
                               "(since PreserveEvents=False). See log.");
    // Replace the "processed" workspace with the converted one.
    MatrixWorkspace_sptr temp = alg->getProperty("OutputWorkspace");
    if (monitorWS)
      temp->setMonitorWorkspace(monitorWS); // Set back the monitor workspace
    processed = temp;
  }

  // How do we accumulate the data?
  std::string accum = this->getPropertyValue("AccumulationMethod");

  // If the AccumulationWorkspace does not exist, we always replace the
  // AccumulationWorkspace.
  // Also, if the listener said we are resetting the data, then we clear out the
  // old.
  if (!m_accumWS || dataReset)
    accum = "Replace";

  g_log.notice() << "Performing the " << accum << " operation.\n";

  // Perform the accumulation and set the AccumulationWorkspace workspace
//.........这里部分代码省略.........
开发者ID:rosswhitfield,项目名称:mantid,代码行数:101,代码来源:LoadLiveData.cpp

示例5:

/** Circumvent a bug in IPython 1.1, which chokes on nanosecond precision
 * datetimes.
 *  Adding a space to the string returned by the C++ method avoids it being
 * given
 *  the special treatment that leads to the problem.
 */
std::string ISO8601StringPlusSpace(DateAndTime &self) {
  return self.toISO8601String() + " ";
}
开发者ID:nimgould,项目名称:mantid,代码行数:9,代码来源:DateAndTime.cpp


注:本文中的DateAndTime::toISO8601String方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。