bes  Updated for version 3.20.6
DODS_Time.h
1 
2 // -*- mode: c++; c-basic-offset:4 -*-
3 
4 // This file is part of ff_handler a FreeForm API handler for the OPeNDAP
5 // DAP2 data server.
6 
7 // Copyright (c) 2005 OPeNDAP, Inc.
8 // Author: James Gallagher <jgallagher@opendap.org>
9 //
10 // This is free software; you can redistribute it and/or modify it under the
11 // terms of the GNU Lesser General Public License as published by the Free
12 // Software Foundation; either version 2.1 of the License, or (at your
13 // option) any later version.
14 //
15 // This software is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 // License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 
26 
27 // (c) COPYRIGHT URI/MIT 1998
28 // Please read the full copyright statement in the file COPYRIGHT.
29 //
30 // Authors:
31 // jhrg,jimg James Gallagher (jgallagher@gso.uri.edu)
32 
33 #ifndef _dods_time_h
34 #define _dods_time_h
35 
36 
37 #include <string>
38 
39 #include "dods-datatypes.h"
40 #include "BaseType.h"
41 
42 using namespace libdap ;
43 
63 class DODS_Time {
64 private:
65  dods_uint32 _hours; // 0--23; regular wall time
66  dods_uint32 _minutes; // 0--59
67  double _seconds; // 0--59.9...
68  double _sec_since_midnight;
69  bool _gmt;
70 
71  static double _eps; // defined as 1.0e-6 in DODS_Time.cc
72 
73 protected:
74 
75 public:
86  DODS_Time(string time);
87 
92  DODS_Time(BaseType *arg);
93 
99  DODS_Time(dods_uint32 hh, dods_uint32 mm, bool gmt = false);
100 
107  DODS_Time(dods_uint32 hh, dods_uint32 mm, double ss, bool gmt = false);
108 
112  DODS_Time();
114 
122  void set(string time);
123 
128  void set(BaseType *arg);
129 
136  void set(int hh, int mm, bool gmt = false);
137 
145  void set(int hh, int mm, double ss, bool gmt = false);
147 
156  string get(bool gmt = true) const;
157 
159  int hours() const;
160 
162  int minutes() const;
163 
165  double seconds() const;
166 
168  bool gmt() const;
169 
172  double seconds_since_midnight() const;
173 
177  double fraction() const;
179 
182  friend int operator==(DODS_Time &t1, DODS_Time &t2);
184 
186  friend int operator!=(DODS_Time &t1, DODS_Time &t2);
187 
189  friend int operator<(DODS_Time &t1, DODS_Time &t2);
190 
192  friend int operator>(DODS_Time &t1, DODS_Time &t2);
193 
195  friend int operator<=(DODS_Time &t1, DODS_Time &t2);
196 
198  friend int operator>=(DODS_Time &t1, DODS_Time &t2);
200 
204  bool OK() const;
205 
207  double get_epsilon() const;
208 
211  void set_epsilon(double eps);
212 
213 };
214 
215 // $Log: DODS_Time.h,v $
216 // Revision 1.7 2003/02/10 23:01:52 jimg
217 // Merged with 3.2.5
218 //
219 // Revision 1.6.2.1 2002/01/22 02:19:35 jimg
220 // Fixed bug 62. Users built fmt files that used types other than int32
221 // for date and time components (e.g. int16). I fixed the factory classes
222 // so that DODS_Date and DODS_Time objects will be built correctly when
223 // any of the integer (or in the case of seconds, float) data types are
224 // used. In so doing I also refactored the factory classes so that code
225 // duplication was reduced (by using inhertiance).
226 // Added two tests for the new capabilities (see date_time.1.exp, the last
227 // two tests).
228 //
229 // Revision 1.6 2000/10/11 19:37:55 jimg
230 // Moved the CVS log entries to the end of files.
231 // Changed the definition of the read method to match the dap library.
232 // Added exception handling.
233 // Added exceptions to the read methods.
234 //
235 // Revision 1.5 1999/07/22 21:28:09 jimg
236 // Merged changes from the release-3-0-2 branch
237 //
238 // Revision 1.4.6.1 1999/06/01 15:38:06 jimg
239 // Added code to parse and return floating point dates.
240 //
241 // Revision 1.4 1999/05/04 02:55:35 jimg
242 // Merge with no-gnu
243 //
244 // Revision 1.3.6.1 1999/05/01 04:40:30 brent
245 // converted old String.h to the new std C++ <string> code
246 //
247 // Revision 1.3 1999/01/08 22:08:19 jimg
248 // Fixed doc++ comments.
249 //
250 // Revision 1.2 1999/01/05 00:37:28 jimg
251 // Removed string class; replaced with the GNU String class. It seems those
252 // don't mix well.
253 // Switched to simpler method names.
254 // Added DOC++ Comments.
255 //
256 // Revision 1.1 1998/12/28 19:07:33 jimg
257 // Initial version of the DODS_Time object
258 //
259 
260 #endif // _dods_time_h
DODS_Time
Definition: DODS_Time.h:63
libdap
Definition: BESDapFunctionResponseCache.h:35