All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TimeDuration.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/datatype/TimeDuration.cpp
22 
23  \brief A class to represent time duration.
24 */
25 
26 // TerraLib
27 #include "TimeDuration.h"
28 
29 te::dt::TimeDuration::TimeDuration(long hours, long minutes, long seconds, boost::int64_t fracSeconds)
30  : m_timeDuration(hours, minutes, seconds, fracSeconds)
31 {
32 }
33 
34 te::dt::TimeDuration::TimeDuration(boost::posix_time::time_duration& t)
35  : m_timeDuration(t)
36 {
37 }
38 
40 {
41  const te::dt::TimeDuration* t = dynamic_cast<const te::dt::TimeDuration*>(&rhs);
42  return m_timeDuration == t->m_timeDuration;
43 }
44 
46 {
47  const te::dt::TimeDuration* t = dynamic_cast<const te::dt::TimeDuration*>(&rhs);
48  return m_timeDuration != t->m_timeDuration;
49 }
50 
52 {
53  const te::dt::TimeDuration* t = dynamic_cast<const te::dt::TimeDuration*>(&rhs);
54  return m_timeDuration < t->m_timeDuration;
55 }
56 
58 {
59  const te::dt::TimeDuration* t = dynamic_cast<const te::dt::TimeDuration*>(&rhs);
60  return m_timeDuration > t->m_timeDuration;
61 }
62 
64 {
65  boost::posix_time::time_duration td(m_timeDuration - rhs.m_timeDuration);
66 
67  return td.total_seconds();
68 }
69 
71 {
72  return new TimeDuration(*this);
73 }
74 
75 std::string te::dt::TimeDuration::toString() const
76 {
77  return boost::posix_time::to_simple_string(m_timeDuration);
78  //return boost::posix_time::to_iso_extended_string(m_timeDuration);
79  //return boost::posix_time::to_iso_string(m_timeDuration);
80 }
81 
83 {
84 }
85 
bool operator<(const DateTime &rhs) const
Operator <.
boost::posix_time::time_duration m_timeDuration
The internal time duration information.
Definition: TimeDuration.h:189
std::string toString() const
It returns the time duration in the ISO textual format (hh:mm:ss,ss).
A class to represent time duration.
TimeDuration(long hours, long minutes, long seconds, boost::int64_t fracSeconds=0)
Constructor.
AbstractData * clone() const
It returns a clone of this object.
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
A class to represent time duration with nano-second/micro-second resolution.
Definition: TimeDuration.h:51
bool operator!=(const DateTime &rhs) const
Operator !=.
bool operator==(const DateTime &rhs) const
Operator ==.
long operator-(const TimeDuration &rhs) const
Operator -.
bool operator>(const DateTime &rhs) const
Operator <.
virtual ~TimeDuration()
Destructor.