CivilTime.hpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk 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
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
39 #ifndef GNSSTK_CIVILTIME_HPP
40 #define GNSSTK_CIVILTIME_HPP
41 
42 #include "TimeTag.hpp"
43 #include "TimeSystem.hpp"
44 
45 namespace gnsstk
46 {
48 
49 
55  class CivilTime : public TimeTag
56  {
57  public:
58 
67  CivilTime( int yr = 0,
68  int mo = 0,
69  int dy = 0,
70  int hr = 0,
71  int mn = 0,
72  double s = 0.0,
73  const TimeSystem& ts = TimeSystem::Unknown )
74  : year(yr), month(mo), day(dy), hour(hr), minute(mn), second(s)
75  { timeSystem = ts; }
76 
81  CivilTime( const CivilTime& right )
82  : year( right.year ), month( right.month ) , day( right.day ),
83  hour( right.hour ), minute( right.minute ), second( right.second )
84  { timeSystem = right.timeSystem; }
85 
93  CivilTime( const TimeTag& right )
94  {
96  }
97 
105  CivilTime( const CommonTime& right )
106  {
107  convertFromCommonTime( right );
108  }
109 
115  CivilTime& operator=( const CivilTime& right );
116 
118  virtual ~CivilTime()
119  {}
121 
123  static const char *MonthNames[];
124 
126  static const char *MonthAbbrevNames[];
127 
128  // The following functions are required by TimeTag.
129  virtual CommonTime convertToCommonTime() const;
130 
131  virtual void convertFromCommonTime( const CommonTime& ct );
132 
135  virtual std::string printf(const std::string& fmt) const;
136 
139  virtual std::string printError( const std::string& fmt) const;
140 
147  virtual bool setFromInfo( const IdToValue& info );
148 
151  virtual std::string getPrintChars() const
152  {
153  return "YymbBdHMSfP";
154  }
155 
157  virtual std::string getDefaultFormat() const
158  {
159  return "%02m/%02d/%04Y %02H:%02M:%02S %P";
160  }
161 
162  virtual bool isValid() const;
163 
164  virtual void reset();
165 
170  static int monthAbbrev(const std::string& amonStr);
171 
176  static int monthLong(const std::string& monStr);
177 
186  bool operator==( const CivilTime& right ) const;
187  bool operator!=( const CivilTime& right ) const;
188  bool operator<( const CivilTime& right ) const;
189  bool operator>( const CivilTime& right ) const;
190  bool operator<=( const CivilTime& right ) const;
191  bool operator>=( const CivilTime& right ) const;
193 
195  double getUTHour() const
196  { return (double)hour + (((minute*60.0)+second)/3600.0); }
197 
198  int year;
199  int month;
200  int day;
201  int hour;
202  int minute;
203  double second;
204 
205  };
207 
208 } // namespace
209 
210  // -----------CivilTime operator<< -----------
211  //
218 std::ostream& operator<<( std::ostream& s,
219  const gnsstk::CivilTime& cit );
220 
221 #endif // GNSSTK_CIVILTIME_HPP
TimeSystem.hpp
gnsstk::CivilTime::operator=
CivilTime & operator=(const CivilTime &right)
Definition: CivilTime.cpp:63
gnsstk::CivilTime::monthLong
static int monthLong(const std::string &monStr)
Definition: CivilTime.cpp:293
gnsstk::CivilTime::operator<=
bool operator<=(const CivilTime &right) const
Definition: CivilTime.cpp:393
gnsstk::CivilTime::year
int year
Definition: CivilTime.hpp:198
gnsstk::CivilTime::printError
virtual std::string printError(const std::string &fmt) const
Definition: CivilTime.cpp:148
gnsstk::TimeTag::IdToValue
std::map< char, std::string > IdToValue
Definition: TimeTag.hpp:103
gnsstk::CivilTime::day
int day
Definition: CivilTime.hpp:200
gnsstk::CivilTime::MonthAbbrevNames
static const char * MonthAbbrevNames[]
Short month names for converstion from numbers to strings.
Definition: CivilTime.hpp:126
gnsstk::CivilTime::CivilTime
CivilTime(const TimeTag &right)
Definition: CivilTime.hpp:93
operator<<
std::ostream & operator<<(std::ostream &s, const gnsstk::CivilTime &cit)
Definition: CivilTime.cpp:404
gnsstk::CivilTime::convertFromCommonTime
virtual void convertFromCommonTime(const CommonTime &ct)
Definition: CivilTime.cpp:97
gnsstk::TimeSystem::Unknown
@ Unknown
unknown time frame; for legacy code compatibility
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::TimeTag::timeSystem
TimeSystem timeSystem
time system (representation) of the data
Definition: TimeTag.hpp:204
gnsstk::CivilTime::~CivilTime
virtual ~CivilTime()
Virtual Destructor.
Definition: CivilTime.hpp:118
gnsstk::TimeTag
Definition: TimeTag.hpp:58
gnsstk::CivilTime::convertToCommonTime
virtual CommonTime convertToCommonTime() const
Definition: CivilTime.cpp:75
gnsstk::CivilTime::monthAbbrev
static int monthAbbrev(const std::string &amonStr)
Definition: CivilTime.cpp:282
gnsstk::CivilTime::printf
virtual std::string printf(const std::string &fmt) const
Definition: CivilTime.cpp:111
gnsstk::CivilTime::operator==
bool operator==(const CivilTime &right) const
Definition: CivilTime.cpp:304
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::TimeSystem
TimeSystem
Definition of various time systems.
Definition: TimeSystem.hpp:51
gnsstk::TimeTag::convertToCommonTime
virtual CommonTime convertToCommonTime() const =0
TimeTag.hpp
gnsstk::CivilTime::CivilTime
CivilTime(int yr=0, int mo=0, int dy=0, int hr=0, int mn=0, double s=0.0, const TimeSystem &ts=TimeSystem::Unknown)
Definition: CivilTime.hpp:67
gnsstk::CivilTime::operator!=
bool operator!=(const CivilTime &right) const
Definition: CivilTime.cpp:324
gnsstk::CivilTime::minute
int minute
Definition: CivilTime.hpp:202
gnsstk::CivilTime::isValid
virtual bool isValid() const
Returns true if this object's members are valid, false otherwise.
Definition: CivilTime.cpp:262
gnsstk::CivilTime
Definition: CivilTime.hpp:55
gnsstk::CivilTime::reset
virtual void reset()
Reset this object to the default state.
Definition: CivilTime.cpp:273
gnsstk::CivilTime::operator<
bool operator<(const CivilTime &right) const
Definition: CivilTime.cpp:329
gnsstk::CivilTime::getDefaultFormat
virtual std::string getDefaultFormat() const
Return a string containing the default format to use in printing.
Definition: CivilTime.hpp:157
gnsstk::CivilTime::operator>=
bool operator>=(const CivilTime &right) const
Definition: CivilTime.cpp:398
gnsstk::CivilTime::CivilTime
CivilTime(const CivilTime &right)
Definition: CivilTime.hpp:81
gnsstk::CivilTime::CivilTime
CivilTime(const CommonTime &right)
Definition: CivilTime.hpp:105
gnsstk::CivilTime::month
int month
Definition: CivilTime.hpp:199
gnsstk::CivilTime::operator>
bool operator>(const CivilTime &right) const
Definition: CivilTime.cpp:388
gnsstk::CivilTime::second
double second
Definition: CivilTime.hpp:203
gnsstk::CivilTime::getPrintChars
virtual std::string getPrintChars() const
Definition: CivilTime.hpp:151
gnsstk::CivilTime::MonthNames
static const char * MonthNames[]
Long month names for converstion from numbers to strings.
Definition: CivilTime.hpp:123
gnsstk::CivilTime::setFromInfo
virtual bool setFromInfo(const IdToValue &info)
Definition: CivilTime.cpp:185
gnsstk::CivilTime::hour
int hour
Definition: CivilTime.hpp:201
gnsstk::CivilTime::getUTHour
double getUTHour() const
Get the "universal time"-esque fractional hour of day.
Definition: CivilTime.hpp:195


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:38