ofstd/include/dcmtk/ofstd/ofdate.h

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: Class for date functions
00019  *
00020  *  Last Update:      $Author: joergr $
00021  *  Update Date:      $Date: 2010-10-14 13:15:50 $
00022  *  CVS/RCS Revision: $Revision: 1.9 $
00023  *  Status:           $State: Exp $
00024  *
00025  *  CVS/RCS Log at end of file
00026  *
00027  */
00028 
00029 
00030 #ifndef OFDATE_H
00031 #define OFDATE_H
00032 
00033 #include "dcmtk/config/osconfig.h"
00034 
00035 BEGIN_EXTERN_C
00036 #ifdef HAVE_SYS_TYPES_H
00037 # include <sys/types.h>    /* for struct time_t */
00038 #endif
00039 END_EXTERN_C
00040 
00041 #include "dcmtk/ofstd/ofstring.h"      /* for class OFString */
00042 #include "dcmtk/ofstd/ofstream.h"      /* for ostream */
00043 
00044 
00045 /*---------------------*
00046  *  class declaration  *
00047  *---------------------*/
00048 
00051 class OFDate
00052 {
00053     // allow class OFDateTime to access protected class members
00054     friend class OFDateTime;
00055 
00056 
00057  public:
00058 
00062     OFDate();
00063 
00067     OFDate(const OFDate &dateVal);
00068 
00074     OFDate(const unsigned int year,
00075            const unsigned int month,
00076            const unsigned int day);
00077 
00080     virtual ~OFDate();
00081 
00086     virtual OFDate &operator=(const OFDate &dateVal);
00087 
00092     virtual OFBool operator==(const OFDate &dateVal) const;
00093 
00098     virtual OFBool operator!=(const OFDate &dateVal) const;
00099 
00105     virtual OFBool operator<(const OFDate &dateVal) const;
00106 
00112     virtual OFBool operator<=(const OFDate &dateVal) const;
00113 
00119     virtual OFBool operator>=(const OFDate &dateVal) const;
00120 
00126     virtual OFBool operator>(const OFDate &dateVal) const;
00127 
00131     virtual void clear();
00132 
00139     virtual OFBool isValid() const;
00140 
00148     OFBool setDate(const unsigned int year,
00149                    const unsigned int month,
00150                    const unsigned int day);
00151 
00157     OFBool setYear(const unsigned int year);
00158 
00164     OFBool setMonth(const unsigned int month);
00165 
00171     OFBool setDay(const unsigned int day);
00172 
00178     OFBool setCurrentDate();
00179 
00186     OFBool setISOFormattedDate(const OFString &formattedDate);
00187 
00191     unsigned int getYear() const;
00192 
00196     unsigned int getMonth() const;
00197 
00201     unsigned int getDay() const;
00202 
00210     OFBool getISOFormattedDate(OFString &formattedDate,
00211                                const OFBool showDelimiter = OFTrue) const;
00212 
00213     /* --- static helper functions --- */
00214 
00218     static OFDate getCurrentDate();
00219 
00220 
00221  protected:
00222 
00229     OFBool setCurrentDate(const time_t &tt);
00230 
00231     /* --- static helper functions --- */
00232 
00242     static OFBool isDateValid(const unsigned int year,
00243                               const unsigned int month,
00244                               const unsigned int day);
00245 
00246 
00247  private:
00248 
00250     unsigned int Year;
00251 
00253     unsigned int Month;
00254 
00256     unsigned int Day;
00257 };
00258 
00259 
00266 STD_NAMESPACE ostream& operator<<(STD_NAMESPACE ostream& stream, const OFDate &dateVal);
00267 
00268 
00269 #endif
00270 
00271 
00272 /*
00273  *
00274  * CVS/RCS Log:
00275  * $Log: ofdate.h,v $
00276  * Revision 1.9  2010-10-14 13:15:50  joergr
00277  * Updated copyright header. Added reference to COPYRIGHT file.
00278  *
00279  * Revision 1.8  2006/08/14 16:42:26  meichel
00280  * Updated all code in module ofstd to correctly compile if the standard
00281  *   namespace has not included into the global one with a "using" directive.
00282  *
00283  * Revision 1.7  2005/12/08 16:05:54  meichel
00284  * Changed include path schema for all DCMTK header files
00285  *
00286  * Revision 1.6  2004/01/16 10:30:39  joergr
00287  * Added setISOFormattedXXX() methods for Date, Time and DateTime.
00288  *
00289  * Revision 1.5  2003/09/15 12:12:56  joergr
00290  * Fixed incorrect/improper comments of the comparision operators. Enhanced
00291  * comment of the default constructor. Made comparison operators const.
00292  *
00293  * Revision 1.4  2003/07/04 13:30:37  meichel
00294  * Added include for ofstream.h, to make sure ofstream is correctly defined
00295  *
00296  * Revision 1.3  2002/05/24 09:43:04  joergr
00297  * Renamed some parameters/variables to avoid ambiguities.
00298  *
00299  * Revision 1.2  2002/04/15 09:38:58  joergr
00300  * Added "include <sys/types.h>" for struct time_t (required for MSVC).
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  */


Generated on 6 Jan 2011 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.5.1