00001 /* 00002 * 00003 * Copyright (C) 2002-2010, OFFIS e.V. 00004 * All rights reserved. See COPYRIGHT file for details. 00005 * 00006 * This software and supporting documentation were developed by 00007 * 00008 * OFFIS e.V. 00009 * R&D Division Health 00010 * Escherweg 2 00011 * D-26121 Oldenburg, Germany 00012 * 00013 * 00014 * Module: ofstd 00015 * 00016 * Author: Joerg Riesmeier 00017 * 00018 * Purpose: Combined class for date and time functions 00019 * 00020 * Last Update: $Author: joergr $ 00021 * Update Date: $Date: 2010-10-14 13:15:50 $ 00022 * CVS/RCS Revision: $Revision: 1.10 $ 00023 * Status: $State: Exp $ 00024 * 00025 * CVS/RCS Log at end of file 00026 * 00027 */ 00028 00029 00030 #ifndef OFDATIME_H 00031 #define OFDATIME_H 00032 00033 #include "dcmtk/config/osconfig.h" 00034 00035 #include "dcmtk/ofstd/ofstring.h" /* for class OFString */ 00036 #include "dcmtk/ofstd/ofdate.h" /* for class OFDate */ 00037 #include "dcmtk/ofstd/oftime.h" /* for class OFTime */ 00038 00039 00040 /*---------------------* 00041 * class declaration * 00042 *---------------------*/ 00043 00046 class OFDateTime 00047 { 00048 00049 public: 00050 00054 OFDateTime(); 00055 00059 OFDateTime(const OFDateTime &dateTime); 00060 00065 OFDateTime(const OFDate &dateVal, 00066 const OFTime &timeVal); 00067 00077 OFDateTime(const unsigned int year, 00078 const unsigned int month, 00079 const unsigned int day, 00080 const unsigned int hour, 00081 const unsigned int minute, 00082 const double second, 00083 const double timeZone = 0); 00084 00087 virtual ~OFDateTime(); 00088 00093 virtual OFDateTime &operator=(const OFDateTime &dateTime); 00094 00102 virtual OFBool operator==(const OFDateTime &dateTime) const; 00103 00111 virtual OFBool operator!=(const OFDateTime &dateTime) const; 00112 00116 virtual void clear(); 00117 00122 virtual OFBool isValid() const; 00123 00135 OFBool setDateTime(const unsigned int year, 00136 const unsigned int month, 00137 const unsigned int day, 00138 const unsigned int hour, 00139 const unsigned int minute, 00140 const double second, 00141 const double timeZone = 0); 00142 00148 OFBool setDate(const OFDate &dateVal); 00149 00155 OFBool setTime(const OFTime &timeVal); 00156 00163 OFBool setDateTime(const OFDate &dateVal, 00164 const OFTime &timeVal); 00165 00171 OFBool setCurrentDateTime(); 00172 00181 OFBool setISOFormattedDateTime(const OFString &formattedDateTime); 00182 00186 const OFDate &getDate() const; 00187 00191 const OFTime &getTime() const; 00192 00208 OFBool getISOFormattedDateTime(OFString &formattedDateTime, 00209 const OFBool showSeconds = OFTrue, 00210 const OFBool showFraction = OFFalse, 00211 const OFBool showTimeZone = OFFalse, 00212 const OFBool showDelimiter = OFTrue) const; 00213 00230 OFBool getISOFormattedDateTime(OFString &formattedDateTime, 00231 const OFBool showSeconds /*= OFTrue*/, 00232 const OFBool showFraction /*= OFFalse*/, 00233 const OFBool showTimeZone /*= OFFalse*/, 00234 const OFBool showDelimiter /*= OFTrue*/, 00235 const OFString &dateTimeSeparator /*= " "*/) const; 00236 00237 /* --- static helper functions --- */ 00238 00242 static OFDateTime getCurrentDateTime(); 00243 00244 00245 private: 00246 00248 OFDate Date; 00249 00251 OFTime Time; 00252 }; 00253 00254 00261 STD_NAMESPACE ostream& operator<<(STD_NAMESPACE ostream& stream, const OFDateTime &dateTime); 00262 00263 00264 #endif 00265 00266 00267 /* 00268 * 00269 * CVS/RCS Log: 00270 * $Log: ofdatime.h,v $ 00271 * Revision 1.10 2010-10-14 13:15:50 joergr 00272 * Updated copyright header. Added reference to COPYRIGHT file. 00273 * 00274 * Revision 1.9 2008-05-21 16:31:22 joergr 00275 * Added new constructor and new setDateTime() method. 00276 * 00277 * Revision 1.8 2006/08/14 16:42:26 meichel 00278 * Updated all code in module ofstd to correctly compile if the standard 00279 * namespace has not included into the global one with a "using" directive. 00280 * 00281 * Revision 1.7 2005/12/08 16:05:55 meichel 00282 * Changed include path schema for all DCMTK header files 00283 * 00284 * Revision 1.6 2004/04/16 12:43:26 joergr 00285 * Restructured code to avoid default parameter values for "complex types" like 00286 * OFString. Required for Sun CC 2.0.1. 00287 * 00288 * Revision 1.5 2004/01/16 10:30:39 joergr 00289 * Added setISOFormattedXXX() methods for Date, Time and DateTime. 00290 * 00291 * Revision 1.4 2003/12/17 15:16:20 joergr 00292 * Added note to the comparison operators that the "day overflow" is not yet 00293 * handled correctly. 00294 * 00295 * Revision 1.3 2003/09/15 12:12:56 joergr 00296 * Fixed incorrect/improper comments of the comparision operators. Enhanced 00297 * comment of the default constructor. Made comparison operators const. 00298 * 00299 * Revision 1.2 2002/05/24 09:43:04 joergr 00300 * Renamed some parameters/variables to avoid ambiguities. 00301 * 00302 * Revision 1.1 2002/04/11 12:12:23 joergr 00303 * Introduced new standard classes providing date and time functions. 00304 * 00305 * 00306 */