bes  Updated for version 3.20.6
DODS_Date_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_date_time_h
34 #define _dods_date_time_h
35 
36 
37 #include "DODS_Date.h"
38 #include "DODS_Time.h"
39 
48  private:
49  DODS_Date _date;
50  DODS_Time _time;
51 
52  void parse_fractional_time(string date_time);
53  public:
58 
64 
69  DODS_Date_Time(string date_time);
70 
75  DODS_Date_Time(BaseType *date_time);
76 
86  DODS_Date_Time(int y, int m, int d, int hh, int mm = 0, double ss = 0.0,
87  bool gmt = false);
88 
97  DODS_Date_Time(int y, int yd, int hh, int mm = 0, double ss = 0.0,
98  bool gmt = false);
100 
107  void set(DODS_Date d, DODS_Time t);
108 
113  void set(string date_time);
114 
119  void set(BaseType *date_time);
120 
130  void set(int y, int m, int d, int hh, int mm = 0,
131  double ss = 0.0, bool gmt = false);
132 
141  void set(int y, int yd, int hh, int mm = 0, double ss = 0.0,
142  bool gmt = false);
144 
148  int year() const;
149 
151  int month() const;
152 
154  int day() const;
155 
157  int day_number() const;
158 
160  int hours() const;
161 
163  int minutes() const;
164 
166  double seconds() const;
167 
169  bool gmt() const;
170 
179  string get(date_format format = ymd, bool gmt = true) const;
180 
183  double julian_day() const;
184 
194  time_t unix_time() const;
196 
199  friend int operator==(DODS_Date_Time &t1, DODS_Date_Time &t2);
201 
203  friend int operator!=(DODS_Date_Time &t1, DODS_Date_Time &t2);
204 
206  friend int operator<(DODS_Date_Time &t1, DODS_Date_Time &t2);
207 
209  friend int operator>(DODS_Date_Time &t1, DODS_Date_Time &t2);
210 
212  friend int operator<=(DODS_Date_Time &t1, DODS_Date_Time &t2);
213 
215  friend int operator>=(DODS_Date_Time &t1, DODS_Date_Time &t2);
217 
219  double get_epsilon() const;
220 
225  void set_epsilon(double eps);
226 
230  bool OK() const;
231 
232 };
233 
234 // $Log: DODS_Date_Time.h,v $
235 // Revision 1.4 2000/10/11 19:37:55 jimg
236 // Moved the CVS log entries to the end of files.
237 // Changed the definition of the read method to match the dap library.
238 // Added exception handling.
239 // Added exceptions to the read methods.
240 //
241 // Revision 1.3 1999/07/22 21:28:09 jimg
242 // Merged changes from the release-3-0-2 branch
243 //
244 // Revision 1.2.6.1 1999/06/01 15:38:06 jimg
245 // Added code to parse and return floating point dates.
246 //
247 // Revision 1.2 1999/05/04 02:55:35 jimg
248 // Merge with no-gnu
249 //
250 // Revision 1.1.6.1 1999/05/01 04:40:30 brent
251 // converted old String.h to the new std C++ <string> code
252 //
253 // Revision 1.1 1999/01/08 22:08:18 jimg
254 // Fixed doc++ comments.
255 //
256 
257 #endif // _dods_date_time_h
DODS_Time
Definition: DODS_Time.h:63
DODS_Date_Time::day_number
int day_number() const
Definition: DODS_Date_Time.cc:265
DODS_Date_Time::year
int year() const
Definition: DODS_Date_Time.cc:247
DODS_Date_Time::get_epsilon
double get_epsilon() const
Definition: DODS_Date_Time.cc:344
DODS_Date_Time::hours
int hours() const
Definition: DODS_Date_Time.cc:271
DODS_Date_Time::set_epsilon
void set_epsilon(double eps)
Definition: DODS_Date_Time.cc:350
DODS_Date
Definition: DODS_Date.h:108
DODS_Date_Time::OK
bool OK() const
Definition: DODS_Date_Time.cc:84
DODS_Date_Time::operator==
friend int operator==(DODS_Date_Time &t1, DODS_Date_Time &t2)
Equality.
Definition: DODS_Date_Time.cc:356
DODS_Date_Time::operator<
friend int operator<(DODS_Date_Time &t1, DODS_Date_Time &t2)
Less-than.
Definition: DODS_Date_Time.cc:368
DODS_Date_Time::operator<=
friend int operator<=(DODS_Date_Time &t1, DODS_Date_Time &t2)
Less-than or Equal-to.
Definition: DODS_Date_Time.cc:382
DODS_Date_Time::operator>
friend int operator>(DODS_Date_Time &t1, DODS_Date_Time &t2)
Greater-than.
Definition: DODS_Date_Time.cc:375
DODS_Date_Time::julian_day
double julian_day() const
Definition: DODS_Date_Time.cc:323
DODS_Date_Time::operator!=
friend int operator!=(DODS_Date_Time &t1, DODS_Date_Time &t2)
Inequality.
Definition: DODS_Date_Time.cc:362
DODS_Date_Time::DODS_Date_Time
DODS_Date_Time()
Definition: DODS_Date_Time.cc:89
DODS_Date_Time::day
int day() const
Definition: DODS_Date_Time.cc:259
DODS_Date_Time::set
void set(DODS_Date d, DODS_Time t)
Definition: DODS_Date_Time.cc:121
DODS_Date_Time::gmt
bool gmt() const
Definition: DODS_Date_Time.cc:289
DODS_Date_Time::month
int month() const
Definition: DODS_Date_Time.cc:253
DODS_Date_Time::operator>=
friend int operator>=(DODS_Date_Time &t1, DODS_Date_Time &t2)
Greater-than or Equal-to.
Definition: DODS_Date_Time.cc:388
DODS_Date_Time::seconds
double seconds() const
Definition: DODS_Date_Time.cc:283
DODS_Date_Time::unix_time
time_t unix_time() const
Definition: DODS_Date_Time.cc:329
DODS_Date_Time::minutes
int minutes() const
Definition: DODS_Date_Time.cc:277
DODS_Date_Time::get
string get(date_format format=ymd, bool gmt=true) const
Definition: DODS_Date_Time.cc:295
DODS_Date_Time
Definition: DODS_Date_Time.h:47