PSTime::Duration Class Reference
[PSTime package]

This class is intended to work with durations in the ISO8601 standard. More...

#include <Duration.h>

List of all members.

Public Types

 PARSE_IS_OK
 DURATION_STRING_TOO_SHORT
 DURATION_STRING_TOO_LONG
 DURATION_STRING_WRONG_FORMAT_MISSING_P
 DURATION_TOO_LONG_FIELD_FOR_YEARS
 DURATION_TOO_LONG_FIELD_FOR_MONTHS
 DURATION_TOO_LONG_FIELD_FOR_DAYS
 DURATION_TOO_LONG_FIELD_FOR_HOURS
 DURATION_TOO_LONG_FIELD_FOR_MINUTES
 DURATION_TOO_LONG_FIELD_FOR_SECONDS
 DURATION_TOO_LONG_FIELD_FOR_SECOND_FRACTION
enum  ParseStatus {
  PARSE_IS_OK, DURATION_STRING_TOO_SHORT, DURATION_STRING_TOO_LONG, DURATION_STRING_WRONG_FORMAT_MISSING_P,
  DURATION_TOO_LONG_FIELD_FOR_YEARS, DURATION_TOO_LONG_FIELD_FOR_MONTHS, DURATION_TOO_LONG_FIELD_FOR_DAYS, DURATION_TOO_LONG_FIELD_FOR_HOURS,
  DURATION_TOO_LONG_FIELD_FOR_MINUTES, DURATION_TOO_LONG_FIELD_FOR_SECONDS, DURATION_TOO_LONG_FIELD_FOR_SECOND_FRACTION
}

Public Member Functions

 Duration ()
 Duration (const Duration &d)
 Duration (time_t sec, time_t nsec=0)
 Duration (time_t Years, time_t Days, time_t Hours, time_t Mins=0, time_t Secs=0, time_t Nsecs=0)
virtual ~Duration ()
Duration operator- (const Duration &d1) const
Duration operator+ (const Duration &d1) const
Durationoperator= (const Duration &d1)
Durationoperator+= (const Duration &d1)
bool operator== (const Duration &d) const
bool operator!= (const Duration &d) const
bool operator< (const Duration &d) const
bool operator> (const Duration &d) const
bool operator<= (const Duration &d) const
bool operator>= (const Duration &d) const
time_t getSec () const
time_t getNsec () const
void Print () const
std::string strDurationBasic () const
void splitDurationSecsForYDHMS (time_t &Years, time_t &DaysAfterY, time_t &HoursAfterD, time_t &MinsAfterH, time_t &SecsAfterM) const

Static Public Member Functions

static int parseStringToDuration (const std::string &str_dur, Duration &d)

Friends

std::ostream & operator<< (std::ostream &os, const Duration &d)


Detailed Description

This class is intended to work with durations in the ISO8601 standard.

This software was developed for the LCLS project. If you use all or part of it, please give an appropriate acknowledgment.

See also:
Time
Version:
$Id: Duration.h 5166 2013-01-25 18:57:11Z salnikov@SLAC.STANFORD.EDU $
Author:
Mikhail S. Dubrovin

Definition at line 41 of file Duration.h.


Member Enumeration Documentation

enum PSTime::Duration::ParseStatus

Enumerator:
PARSE_IS_OK 
DURATION_STRING_TOO_SHORT 
DURATION_STRING_TOO_LONG 
DURATION_STRING_WRONG_FORMAT_MISSING_P 
DURATION_TOO_LONG_FIELD_FOR_YEARS 
DURATION_TOO_LONG_FIELD_FOR_MONTHS 
DURATION_TOO_LONG_FIELD_FOR_DAYS 
DURATION_TOO_LONG_FIELD_FOR_HOURS 
DURATION_TOO_LONG_FIELD_FOR_MINUTES 
DURATION_TOO_LONG_FIELD_FOR_SECONDS 
DURATION_TOO_LONG_FIELD_FOR_SECOND_FRACTION 

Definition at line 44 of file Duration.h.


Constructor & Destructor Documentation

PSTime::Duration::Duration (  ) 

Default constructor

Definition at line 42 of file Duration.cpp.

PSTime::Duration::Duration ( const Duration d  ) 

Copy constructor

Definition at line 47 of file Duration.cpp.

PSTime::Duration::Duration ( time_t  sec,
time_t  nsec = 0 
)

Constructs from seconds and nanoseconds

Definition at line 52 of file Duration.cpp.

References nsecInASec.

PSTime::Duration::Duration ( time_t  Years,
time_t  Days,
time_t  Hours,
time_t  Mins = 0,
time_t  Secs = 0,
time_t  Nsecs = 0 
)

Constructs from human numbers In this implementation I ignore monthes, because they may have ambigous number of days 30 or 31. The same problem exists for years 364 or 365 days, though I hope that so long duration is not very practical in our applications.

Definition at line 68 of file Duration.cpp.

virtual PSTime::Duration::~Duration (  )  [inline, virtual]

Destructor

Definition at line 81 of file Duration.h.


Member Function Documentation

time_t PSTime::Duration::getNsec (  )  const [inline]

Definition at line 124 of file Duration.h.

Referenced by PSTime::Time::operator+=(), and PSTime::Time::operator-=().

time_t PSTime::Duration::getSec (  )  const [inline]

Selectors

Definition at line 123 of file Duration.h.

Referenced by PSTime::Time::operator+=(), and PSTime::Time::operator-=().

bool PSTime::Duration::operator!= ( const Duration d  )  const [inline]

Definition at line 97 of file Duration.h.

Duration PSTime::Duration::operator+ ( const Duration d1  )  const

Definition at line 127 of file Duration.cpp.

References m_nsec, m_sec, and nsecInASec.

Duration & PSTime::Duration::operator+= ( const Duration d1  ) 

Definition at line 157 of file Duration.cpp.

References m_nsec, m_sec, and nsecInASec.

Duration PSTime::Duration::operator- ( const Duration d1  )  const

Operators

Definition at line 87 of file Duration.cpp.

References m_nsec, m_sec, and nsecInASec.

bool PSTime::Duration::operator< ( const Duration d  )  const [inline]

Definition at line 102 of file Duration.h.

References m_nsec, and m_sec.

bool PSTime::Duration::operator<= ( const Duration d  )  const [inline]

Definition at line 112 of file Duration.h.

Duration & PSTime::Duration::operator= ( const Duration d1  ) 

Definition at line 148 of file Duration.cpp.

References m_nsec, and m_sec.

bool PSTime::Duration::operator== ( const Duration d  )  const [inline]

Definition at line 92 of file Duration.h.

References m_nsec, and m_sec.

bool PSTime::Duration::operator> ( const Duration d  )  const [inline]

Definition at line 107 of file Duration.h.

References m_nsec, and m_sec.

bool PSTime::Duration::operator>= ( const Duration d  )  const [inline]

Definition at line 117 of file Duration.h.

int PSTime::Duration::parseStringToDuration ( const std::string &  str_dur,
Duration d 
) [static]

The parsification engine, the string in standard format P[nY][nM][nD][T[nH][nM][n[.f]S]] is parsed in the Duration object. Note, we assume that the monnth M has 30 days..., so it is better to escape this ambiguity using any number of days D. Also note that seconds S may be fractional: n[.f]S, that is beyond the ISO8601 standard.

Definition at line 250 of file Duration.cpp.

References DURATION_STRING_TOO_LONG, DURATION_STRING_TOO_SHORT, DURATION_STRING_WRONG_FORMAT_MISSING_P, DURATION_TOO_LONG_FIELD_FOR_DAYS, DURATION_TOO_LONG_FIELD_FOR_HOURS, DURATION_TOO_LONG_FIELD_FOR_MINUTES, DURATION_TOO_LONG_FIELD_FOR_MONTHS, DURATION_TOO_LONG_FIELD_FOR_SECOND_FRACTION, DURATION_TOO_LONG_FIELD_FOR_SECONDS, DURATION_TOO_LONG_FIELD_FOR_YEARS, m_nsec, m_sec, and PARSE_IS_OK.

void PSTime::Duration::Print (  )  const

Public methods

Definition at line 180 of file Duration.cpp.

References splitDurationSecsForYDHMS(), and strDurationBasic().

void PSTime::Duration::splitDurationSecsForYDHMS ( time_t &  Years,
time_t &  DaysAfterY,
time_t &  HoursAfterD,
time_t &  MinsAfterH,
time_t &  SecsAfterM 
) const

Splits the Duration object entity for Years, DaysAfterY, HoursAfterD, MinsAfterH, SecsAfterM Note, the month are not used because of 28,29,30,31 days ambiguity.

Definition at line 379 of file Duration.cpp.

Referenced by Print(), and strDurationBasic().

string PSTime::Duration::strDurationBasic (  )  const

Makes the duration string in the format: PnYnMnDTnHnMnS from the object entity.

Definition at line 213 of file Duration.cpp.

References splitDurationSecsForYDHMS().

Referenced by Print().


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Duration d 
) [friend]

Friends

Definition at line 401 of file Duration.cpp.


The documentation for this class was generated from the following files:
Generated on 19 Dec 2016 for PSANAclasses by  doxygen 1.4.7