gtime.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2013 Graeme Walker <graeme_walker@users.sourceforge.net>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
20 
21 #ifndef G_TIME_H
22 #define G_TIME_H
23 
24 #include "gdef.h"
25 #include "gexception.h"
26 #include "gdatetime.h"
27 #include <ctime>
28 
30 namespace G
31 {
32  class Time ;
33 }
34 
39 class G::Time
40 {
41 public:
43  class LocalTime
44  {} ;
45 
46  Time() ;
48 
49  explicit Time( const G::DateTime::BrokenDownTime & tm ) ;
51 
52  explicit Time( G::DateTime::EpochTime t ) ;
54 
55  Time( G::DateTime::EpochTime t , const LocalTime & ) ;
57 
58  explicit Time( const LocalTime & ) ;
60 
61  int hours() const ;
63 
64  int minutes() const ;
66 
67  int seconds() const ;
69 
70  std::string hhmmss( const char * sep = NULL ) const ;
72 
73  std::string hhmm( const char * sep = NULL ) const ;
75 
76  std::string ss() const ;
78 
79 private:
80  int m_hh ;
81  int m_mm ;
82  int m_ss ;
83 } ;
84 
85 #endif
std::time_t EpochTime
Definition: gdatetime.h:41
std::string hhmm(const char *sep=NULL) const
Returns a hhmm string.
Definition: gtime.cpp:88
std::string ss() const
Returns the seconds as a two-digit decimal seconds.
Definition: gtime.cpp:96
A simple time-of-day (hh/mm/ss) class.
Definition: gtime.h:39
Time()
Constructor, using UTC, for now.
Definition: gtime.cpp:33
Low-level classes.
An overload discriminator class for Time constructors.
Definition: gtime.h:43
int minutes() const
Returns the minutes (0 <= m < 60).
Definition: gtime.cpp:70
int hours() const
Returns the hours (0 <= h < 24).
Definition: gtime.cpp:65
struct std::tm BrokenDownTime
Definition: gdatetime.h:43
std::string hhmmss(const char *sep=NULL) const
Returns a hhmmss string.
Definition: gtime.cpp:80
int seconds() const
Returns the seconds (0 <= s <= 61 [sic]).
Definition: gtime.cpp:75