OFFIS DCMTK  Version 3.6.0
oftime.h
1 /*
2  *
3  * Copyright (C) 2002-2010, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: ofstd
15  *
16  * Author: Joerg Riesmeier
17  *
18  * Purpose: Class for time functions
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-10-14 13:15:50 $
22  * CVS/RCS Revision: $Revision: 1.11 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 
30 #ifndef OFTIME_H
31 #define OFTIME_H
32 
33 #include "dcmtk/config/osconfig.h"
34 
35 #define INCLUDE_CTIME
36 #include "dcmtk/ofstd/ofstdinc.h"
37 
38 BEGIN_EXTERN_C
39 #ifdef HAVE_SYS_TYPES_H
40 # include <sys/types.h> /* for struct time_t */
41 #endif
42 END_EXTERN_C
43 
44 #include "dcmtk/ofstd/ofstring.h" /* for class OFString */
45 
46 
47 /*---------------------*
48  * class declaration *
49  *---------------------*/
50 
53 class OFTime
54 {
55  // allow class OFDateTime to access protected class members
56  friend class OFDateTime;
57 
58 
59  public:
60 
64  OFTime();
65 
69  OFTime(const OFTime &timeVal);
70 
77  OFTime(const unsigned int hour,
78  const unsigned int minute,
79  const double second,
80  const double timeZone = 0);
81 
84  virtual ~OFTime();
85 
90  virtual OFTime &operator=(const OFTime &timeVal);
91 
98  virtual OFBool operator==(const OFTime &timeVal) const;
99 
106  virtual OFBool operator!=(const OFTime &timeVal) const;
107 
114  virtual OFBool operator<(const OFTime &timeVal) const;
115 
123  virtual OFBool operator<=(const OFTime &timeVal) const;
124 
132  virtual OFBool operator>=(const OFTime &timeVal) const;
133 
140  virtual OFBool operator>(const OFTime &timeVal) const;
141 
145  virtual void clear();
146 
152  virtual OFBool isValid() const;
153 
162  OFBool setTime(const unsigned int hour,
163  const unsigned int minute,
164  const double second,
165  const double timeZone = 0);
166 
172  OFBool setHour(const unsigned int hour);
173 
179  OFBool setMinute(const unsigned int minute);
180 
186  OFBool setSecond(const double second);
187 
196  OFBool setTimeZone(const double timeZone);
197 
206  OFBool setTimeZone(const signed int hour,
207  const unsigned int minute);
208 
216  OFBool setTimeInSeconds(const double seconds,
217  const double timeZone = 0,
218  const OFBool normalize = OFTrue);
219 
227  OFBool setTimeInHours(const double hours,
228  const double timeZone = 0,
229  const OFBool normalize = OFTrue);
230 
236  OFBool setCurrentTime();
237 
246  OFBool setISOFormattedTime(const OFString &formattedTime);
247 
251  unsigned int getHour() const;
252 
256  unsigned int getMinute() const;
257 
261  double getSecond() const;
262 
266  unsigned int getIntSecond() const;
267 
271  unsigned int getMilliSecond() const;
272 
276  unsigned int getMicroSecond() const;
277 
284  double getTimeZone() const;
285 
292  double getTimeInSeconds(const OFBool useTimeZone = OFFalse,
293  const OFBool normalize = OFTrue) const;
294 
301  double getTimeInHours(const OFBool useTimeZone = OFFalse,
302  const OFBool normalize = OFTrue) const;
303 
310 
315  OFTime getLocalTime() const;
316 
331  OFBool getISOFormattedTime(OFString &formattedTime,
332  const OFBool showSeconds = OFTrue,
333  const OFBool showFraction = OFFalse,
334  const OFBool showTimeZone = OFFalse,
335  const OFBool showDelimiter = OFTrue) const;
336 
337  /* --- static helper functions --- */
338 
342  static OFTime getCurrentTime();
343 
349  static double getLocalTimeZone();
350 
351 
352  protected:
353 
360  OFBool setCurrentTime(const time_t &tt);
361 
362  /* --- static helper functions --- */
363 
373  static OFBool isTimeValid(const unsigned int hour,
374  const unsigned int minute,
375  const double second,
376  const double timeZone);
377 
387  static double getTimeInSeconds(const unsigned int hour,
388  const unsigned int minute,
389  const double second,
390  const double timeZone = 0,
391  const OFBool normalize = OFTrue);
392 
402  static double getTimeInHours(const unsigned int hour,
403  const unsigned int minute,
404  const double second,
405  const double timeZone = 0,
406  const OFBool normalize = OFTrue);
407 
408 
409  private:
410 
412  unsigned int Hour;
413 
415  unsigned int Minute;
416 
418  double Second;
419 
421  double TimeZone;
422 };
423 
424 
431 STD_NAMESPACE ostream& operator<<(STD_NAMESPACE ostream& stream, const OFTime &timeVal);
432 
433 
434 #endif
435 
436 
437 /*
438  *
439  * CVS/RCS Log:
440  * $Log: oftime.h,v $
441  * Revision 1.11 2010-10-14 13:15:50 joergr
442  * Updated copyright header. Added reference to COPYRIGHT file.
443  *
444  * Revision 1.10 2009-08-19 11:55:45 meichel
445  * Added additional includes needed for Sun Studio 11 on Solaris.
446  *
447  * Revision 1.9 2006-08-14 16:42:26 meichel
448  * Updated all code in module ofstd to correctly compile if the standard
449  * namespace has not included into the global one with a "using" directive.
450  *
451  * Revision 1.8 2005/12/08 16:06:09 meichel
452  * Changed include path schema for all DCMTK header files
453  *
454  * Revision 1.7 2004/01/16 10:30:39 joergr
455  * Added setISOFormattedXXX() methods for Date, Time and DateTime.
456  *
457  * Revision 1.6 2003/12/17 15:18:48 joergr
458  * Fixed bug/inconsistency in comparison operators of class OFTime. Now the
459  * "time overflow" is handled correctly.
460  *
461  * Revision 1.5 2003/09/15 12:12:56 joergr
462  * Fixed incorrect/improper comments of the comparision operators. Enhanced
463  * comment of the default constructor. Made comparison operators const.
464  *
465  * Revision 1.4 2002/05/24 09:43:05 joergr
466  * Renamed some parameters/variables to avoid ambiguities.
467  *
468  * Revision 1.3 2002/04/19 10:42:51 joergr
469  * Added new helper routines to get the milli and micro seconds part as well as
470  * the integral value of seconds.
471  *
472  * Revision 1.2 2002/04/15 09:38:59 joergr
473  * Added "include <sys/types.h>" for struct time_t (required for MSVC).
474  *
475  * Revision 1.1 2002/04/11 12:12:24 joergr
476  * Introduced new standard classes providing date and time functions.
477  *
478  *
479  */


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2