TimeInstantTZ.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/TimeInstantTZ.cpp
22 
23  \brief A class to represent time instant with time zone.
24 */
25 
26 // TerraLib
27 #include "TimeInstantTZ.h"
28 #include "Exception.h"
29 #include "../core/translator/Translator.h"
30 
32 {
33  const te::dt::TimeInstantTZ* t = dynamic_cast<const te::dt::TimeInstantTZ*>(&rhs);
34  return m_timeInstantTZ == t->m_timeInstantTZ;
35 }
36 
38 {
39  const te::dt::TimeInstantTZ* t = dynamic_cast<const te::dt::TimeInstantTZ*>(&rhs);
40  return m_timeInstantTZ != t->m_timeInstantTZ;
41 }
42 
44 {
45  const te::dt::TimeInstantTZ* t = dynamic_cast<const te::dt::TimeInstantTZ*>(&rhs);
46  return m_timeInstantTZ < t->m_timeInstantTZ;
47 }
48 
50 {
51  const te::dt::TimeInstantTZ* t = dynamic_cast<const te::dt::TimeInstantTZ*>(&rhs);
52  return m_timeInstantTZ > t->m_timeInstantTZ;
53 }
54 
56 {
57  boost::posix_time::time_duration td(m_timeInstantTZ - rhs.m_timeInstantTZ);
58  return static_cast<long>(td.total_seconds());
59 }
60 
62 {
63  return new TimeInstantTZ(*this);
64 }
65 
67 {
68  std::string t;
69 
70  if(m_timeInstantTZ.is_special())
71  return "";
72 
73  t = boost::posix_time::to_simple_string(m_timeInstantTZ.utc_time());
74 
75  if(m_timeInstantTZ.zone().get() != nullptr)
76  t += m_timeInstantTZ.zone()->to_posix_string();
77 
78  return t;
79 }
80 
81 te::dt::TimeInstantTZ::TimeInstantTZ(const boost::local_time::local_date_time& t)
82  : m_timeInstantTZ(t)
83 {
84 }
85 
static te::dt::TimeDuration td(20, 30, 50, 11)
bool operator==(const DateTime &rhs) const
Operator ==.
bool operator<(const DateTime &rhs) const
Operator <.
bool operator>(const DateTime &rhs) const
Operator >
virtual ~TimeInstantTZ()
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 instant with time zone.
long operator-(const TimeInstantTZ &rhs) const
Operator -.
boost::local_time::local_date_time m_timeInstantTZ
Time instant with time zone information.
bool operator!=(const DateTime &rhs) const
Operator !=.
A class to represent time instant with time zone.
Definition: TimeInstantTZ.h:52
std::string toString() const
It returns the time instant with time zone in the ISO textual format (YYYYMMDDThhmmss?hhmm).
An exception class for the DataType module.
TimeInstantTZ(const boost::local_time::local_date_time &t)
Constructor.