fipa_acl  1.4
Classes | Public Types | Public Member Functions | List of all members
convertToBaseTimeImpl Struct Reference

#include <grammar_common.h>

Classes

struct  result
 

Public Types

typedef base::Time result_type
 

Public Member Functions

template<typename T >
result_type operator() (T arg) const
 
result_type operator() (fipa::acl::DateTime arg) const
 
result_type operator() (std::string arg) const
 

Detailed Description

Convert Time to base::Time

Definition at line 522 of file grammar_common.h.

Member Typedef Documentation

Definition at line 524 of file grammar_common.h.

Member Function Documentation

template<typename T >
result_type convertToBaseTimeImpl::operator() ( arg) const
inline

Definition at line 533 of file grammar_common.h.

534  {
535  return arg.toTime();
536  }
result_type convertToBaseTimeImpl::operator() ( fipa::acl::DateTime  arg) const
inline

Definition at line 538 of file grammar_common.h.

539  {
540  return arg.toTime();
541  }
base::Time toTime() const
Definition: date_time.cpp:28
result_type convertToBaseTimeImpl::operator() ( std::string  arg) const
inline

Definition at line 543 of file grammar_common.h.

544  {
545  std::string time = arg;
546  if ( arg.data()[0] == '-' || arg.data()[0] == '+')
547  {
548  time.erase(0,1);
549  }
550  std::string format = "%Y%m%dT%H%M%S";
551 
552  size_t end = time.find_last_of("0123456789", time.size() -1);
553  if( end < time.size() - 1)
554  {
555  // the type designator is present
556  format += "%Z";
557  }
558 
559  // Shift millisecond so that base::Time understands
560  // the format
561  std::string milliseconds = time.substr(end-2,3);
562  time.erase(end-2,3);
563  time += ":" + milliseconds;
564 
565  return base::Time::fromString(time, base::Time::Milliseconds, format);
566 
567  }

The documentation for this struct was generated from the following file: