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  */
unsigned int getIntSecond() const
get the integral part of the currently stored second value
virtual void clear()
reset the time value.
OFTime getLocalTime() const
get the currently stored time in local time.
static OFBool isTimeValid(const unsigned int hour, const unsigned int minute, const double second, const double timeZone)
check whether the given time is valid.
OFBool setISOFormattedTime(const OFString &formattedTime)
set the time value to the given ISO formatted time string.
virtual OFTime & operator=(const OFTime &timeVal)
assignment operator
virtual OFBool operator<=(const OFTime &timeVal) const
comparison operator (less than or equal) Please note that the time values are first transformed to th...
This class provides a collection of time functions.
Definition: oftime.h:53
virtual OFBool operator>=(const OFTime &timeVal) const
comparison operator (greater than or equal) Please note that the time values are first transformed to...
double Second
currently stored second value (incl. fraction of seconds)
Definition: oftime.h:418
virtual OFBool isValid() const
check whether the currently stored time value is valid.
double getTimeInHours(const OFBool useTimeZone=OFFalse, const OFBool normalize=OFTrue) const
get the currently stored time in hours.
static OFTime getCurrentTime()
get the current system time
double TimeZone
currently stored time zone value
Definition: oftime.h:421
OFTime()
default constructor.
OFBool setTimeInSeconds(const double seconds, const double timeZone=0, const OFBool normalize=OFTrue)
set the time to the specified number of seconds
virtual OFBool operator<(const OFTime &timeVal) const
comparison operator (less than) Please note that the time values are first transformed to the Coordin...
unsigned int Minute
currently stored minute value
Definition: oftime.h:415
OFBool setHour(const unsigned int hour)
set the time value to the specified hour.
OFBool getISOFormattedTime(OFString &formattedTime, const OFBool showSeconds=OFTrue, const OFBool showFraction=OFFalse, const OFBool showTimeZone=OFFalse, const OFBool showDelimiter=OFTrue) const
get the current time value in ISO format.
virtual ~OFTime()
destructor
double getTimeZone() const
get the currently stored time zone value.
static double getLocalTimeZone()
get the local time zone.
OFBool setTimeInHours(const double hours, const double timeZone=0, const OFBool normalize=OFTrue)
set the time to the specified number of hours
This class is a combination of OFDate and OFTime.
Definition: ofdatime.h:46
unsigned int getMicroSecond() const
get the micro second part of the currently stored second value
double getSecond() const
get the currently stored second value
unsigned int getMilliSecond() const
get the milli second part of the currently stored second value
virtual OFBool operator>(const OFTime &timeVal) const
comparison operator (greater than) Please note that the time values are first transformed to the Coor...
virtual OFBool operator!=(const OFTime &timeVal) const
comparison operator (unequal) Please note that the time values are first transformed to the Coordinat...
a simple string class that implements a subset of std::string.
Definition: ofstring.h:86
OFBool setTime(const unsigned int hour, const unsigned int minute, const double second, const double timeZone=0)
set the time value to the specified time.
unsigned int getMinute() const
get the currently stored minute value
double getTimeInSeconds(const OFBool useTimeZone=OFFalse, const OFBool normalize=OFTrue) const
get the currently stored time in seconds
OFBool setCurrentTime()
set the time value to the current system time.
OFTime getCoordinatedUniversalTime() const
get the currently stored time as Coordinated Universal Time.
unsigned int getHour() const
get the currently stored hour value
OFBool setMinute(const unsigned int minute)
set the time value to the specified minute.
OFBool setTimeZone(const double timeZone)
set the time zone to the specified value.
unsigned int Hour
currently stored hour value
Definition: oftime.h:412
virtual OFBool operator==(const OFTime &timeVal) const
comparison operator (equal).
OFBool setSecond(const double second)
set the time value to the specified second.


Generated on Wed Dec 28 2016 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.8