00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef OFTIME_H
00035 #define OFTIME_H
00036
00037 #include "dcmtk/config/osconfig.h"
00038
00039 BEGIN_EXTERN_C
00040 #ifdef HAVE_SYS_TYPES_H
00041 # include <sys/types.h>
00042 #endif
00043 END_EXTERN_C
00044
00045 #include "dcmtk/ofstd/ofstring.h"
00046
00047
00048
00049
00050
00051
00054 class OFTime
00055 {
00056
00057 friend class OFDateTime;
00058
00059
00060 public:
00061
00065 OFTime();
00066
00070 OFTime(const OFTime &timeVal);
00071
00078 OFTime(const unsigned int hour,
00079 const unsigned int minute,
00080 const double second,
00081 const double timeZone = 0);
00082
00085 virtual ~OFTime();
00086
00091 virtual OFTime &operator=(const OFTime &timeVal);
00092
00099 virtual OFBool operator==(const OFTime &timeVal) const;
00100
00107 virtual OFBool operator!=(const OFTime &timeVal) const;
00108
00115 virtual OFBool operator<(const OFTime &timeVal) const;
00116
00124 virtual OFBool operator<=(const OFTime &timeVal) const;
00125
00133 virtual OFBool operator>=(const OFTime &timeVal) const;
00134
00141 virtual OFBool operator>(const OFTime &timeVal) const;
00142
00146 virtual void clear();
00147
00153 virtual OFBool isValid() const;
00154
00163 OFBool setTime(const unsigned int hour,
00164 const unsigned int minute,
00165 const double second,
00166 const double timeZone = 0);
00167
00173 OFBool setHour(const unsigned int hour);
00174
00180 OFBool setMinute(const unsigned int minute);
00181
00187 OFBool setSecond(const double second);
00188
00197 OFBool setTimeZone(const double timeZone);
00198
00207 OFBool setTimeZone(const signed int hour,
00208 const unsigned int minute);
00209
00217 OFBool setTimeInSeconds(const double seconds,
00218 const double timeZone = 0,
00219 const OFBool normalize = OFTrue);
00220
00228 OFBool setTimeInHours(const double hours,
00229 const double timeZone = 0,
00230 const OFBool normalize = OFTrue);
00231
00237 OFBool setCurrentTime();
00238
00247 OFBool setISOFormattedTime(const OFString &formattedTime);
00248
00252 unsigned int getHour() const;
00253
00257 unsigned int getMinute() const;
00258
00262 double getSecond() const;
00263
00267 unsigned int getIntSecond() const;
00268
00272 unsigned int getMilliSecond() const;
00273
00277 unsigned int getMicroSecond() const;
00278
00285 double getTimeZone() const;
00286
00293 double getTimeInSeconds(const OFBool useTimeZone = OFFalse,
00294 const OFBool normalize = OFTrue) const;
00295
00302 double getTimeInHours(const OFBool useTimeZone = OFFalse,
00303 const OFBool normalize = OFTrue) const;
00304
00310 OFTime getCoordinatedUniversalTime() const;
00311
00316 OFTime getLocalTime() const;
00317
00332 OFBool getISOFormattedTime(OFString &formattedTime,
00333 const OFBool showSeconds = OFTrue,
00334 const OFBool showFraction = OFFalse,
00335 const OFBool showTimeZone = OFFalse,
00336 const OFBool showDelimiter = OFTrue) const;
00337
00338
00339
00343 static OFTime getCurrentTime();
00344
00350 static double getLocalTimeZone();
00351
00352
00353 protected:
00354
00361 OFBool setCurrentTime(const time_t &tt);
00362
00363
00364
00374 static OFBool isTimeValid(const unsigned int hour,
00375 const unsigned int minute,
00376 const double second,
00377 const double timeZone);
00378
00388 static double getTimeInSeconds(const unsigned int hour,
00389 const unsigned int minute,
00390 const double second,
00391 const double timeZone = 0,
00392 const OFBool normalize = OFTrue);
00393
00403 static double getTimeInHours(const unsigned int hour,
00404 const unsigned int minute,
00405 const double second,
00406 const double timeZone = 0,
00407 const OFBool normalize = OFTrue);
00408
00409
00410 private:
00411
00413 unsigned int Hour;
00414
00416 unsigned int Minute;
00417
00419 double Second;
00420
00422 double TimeZone;
00423 };
00424
00425
00432 ostream& operator<<(ostream& stream, const OFTime &timeVal);
00433
00434
00435 #endif
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470