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 #ifndef OFTIME_H
00031 #define OFTIME_H
00032
00033 #include "dcmtk/config/osconfig.h"
00034
00035 #define INCLUDE_CTIME
00036 #include "dcmtk/ofstd/ofstdinc.h"
00037
00038 BEGIN_EXTERN_C
00039 #ifdef HAVE_SYS_TYPES_H
00040 # include <sys/types.h>
00041 #endif
00042 END_EXTERN_C
00043
00044 #include "dcmtk/ofstd/ofstring.h"
00045
00046
00047
00048
00049
00050
00053 class OFTime
00054 {
00055
00056 friend class OFDateTime;
00057
00058
00059 public:
00060
00064 OFTime();
00065
00069 OFTime(const OFTime &timeVal);
00070
00077 OFTime(const unsigned int hour,
00078 const unsigned int minute,
00079 const double second,
00080 const double timeZone = 0);
00081
00084 virtual ~OFTime();
00085
00090 virtual OFTime &operator=(const OFTime &timeVal);
00091
00098 virtual OFBool operator==(const OFTime &timeVal) const;
00099
00106 virtual OFBool operator!=(const OFTime &timeVal) const;
00107
00114 virtual OFBool operator<(const OFTime &timeVal) const;
00115
00123 virtual OFBool operator<=(const OFTime &timeVal) const;
00124
00132 virtual OFBool operator>=(const OFTime &timeVal) const;
00133
00140 virtual OFBool operator>(const OFTime &timeVal) const;
00141
00145 virtual void clear();
00146
00152 virtual OFBool isValid() const;
00153
00162 OFBool setTime(const unsigned int hour,
00163 const unsigned int minute,
00164 const double second,
00165 const double timeZone = 0);
00166
00172 OFBool setHour(const unsigned int hour);
00173
00179 OFBool setMinute(const unsigned int minute);
00180
00186 OFBool setSecond(const double second);
00187
00196 OFBool setTimeZone(const double timeZone);
00197
00206 OFBool setTimeZone(const signed int hour,
00207 const unsigned int minute);
00208
00216 OFBool setTimeInSeconds(const double seconds,
00217 const double timeZone = 0,
00218 const OFBool normalize = OFTrue);
00219
00227 OFBool setTimeInHours(const double hours,
00228 const double timeZone = 0,
00229 const OFBool normalize = OFTrue);
00230
00236 OFBool setCurrentTime();
00237
00246 OFBool setISOFormattedTime(const OFString &formattedTime);
00247
00251 unsigned int getHour() const;
00252
00256 unsigned int getMinute() const;
00257
00261 double getSecond() const;
00262
00266 unsigned int getIntSecond() const;
00267
00271 unsigned int getMilliSecond() const;
00272
00276 unsigned int getMicroSecond() const;
00277
00284 double getTimeZone() const;
00285
00292 double getTimeInSeconds(const OFBool useTimeZone = OFFalse,
00293 const OFBool normalize = OFTrue) const;
00294
00301 double getTimeInHours(const OFBool useTimeZone = OFFalse,
00302 const OFBool normalize = OFTrue) const;
00303
00309 OFTime getCoordinatedUniversalTime() const;
00310
00315 OFTime getLocalTime() const;
00316
00331 OFBool getISOFormattedTime(OFString &formattedTime,
00332 const OFBool showSeconds = OFTrue,
00333 const OFBool showFraction = OFFalse,
00334 const OFBool showTimeZone = OFFalse,
00335 const OFBool showDelimiter = OFTrue) const;
00336
00337
00338
00342 static OFTime getCurrentTime();
00343
00349 static double getLocalTimeZone();
00350
00351
00352 protected:
00353
00360 OFBool setCurrentTime(const time_t &tt);
00361
00362
00363
00373 static OFBool isTimeValid(const unsigned int hour,
00374 const unsigned int minute,
00375 const double second,
00376 const double timeZone);
00377
00387 static double getTimeInSeconds(const unsigned int hour,
00388 const unsigned int minute,
00389 const double second,
00390 const double timeZone = 0,
00391 const OFBool normalize = OFTrue);
00392
00402 static double getTimeInHours(const unsigned int hour,
00403 const unsigned int minute,
00404 const double second,
00405 const double timeZone = 0,
00406 const OFBool normalize = OFTrue);
00407
00408
00409 private:
00410
00412 unsigned int Hour;
00413
00415 unsigned int Minute;
00416
00418 double Second;
00419
00421 double TimeZone;
00422 };
00423
00424
00431 STD_NAMESPACE ostream& operator<<(STD_NAMESPACE ostream& stream, const OFTime &timeVal);
00432
00433
00434 #endif
00435
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
00471
00472
00473
00474
00475
00476
00477
00478
00479