ofdate.h

00001 /*
00002  *
00003  *  Copyright (C) 2002-2005, OFFIS
00004  *
00005  *  This software and supporting documentation were developed by
00006  *
00007  *    Kuratorium OFFIS e.V.
00008  *    Healthcare Information and Communication Systems
00009  *    Escherweg 2
00010  *    D-26121 Oldenburg, Germany
00011  *
00012  *  THIS SOFTWARE IS MADE AVAILABLE,  AS IS,  AND OFFIS MAKES NO  WARRANTY
00013  *  REGARDING  THE  SOFTWARE,  ITS  PERFORMANCE,  ITS  MERCHANTABILITY  OR
00014  *  FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES  OR
00015  *  ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND
00016  *  PERFORMANCE OF THE SOFTWARE IS WITH THE USER.
00017  *
00018  *  Module:  ofstd
00019  *
00020  *  Author:  Joerg Riesmeier
00021  *
00022  *  Purpose: Class for date functions
00023  *
00024  *  Last Update:      $Author: meichel $
00025  *  Update Date:      $Date: 2005/12/08 16:05:54 $
00026  *  CVS/RCS Revision: $Revision: 1.7 $
00027  *  Status:           $State: Exp $
00028  *
00029  *  CVS/RCS Log at end of file
00030  *
00031  */
00032 
00033 
00034 #ifndef OFDATE_H
00035 #define OFDATE_H
00036 
00037 #include "dcmtk/config/osconfig.h"
00038 
00039 BEGIN_EXTERN_C
00040 #ifdef HAVE_SYS_TYPES_H
00041 # include <sys/types.h>    /* for struct time_t */
00042 #endif
00043 END_EXTERN_C
00044 
00045 #include "dcmtk/ofstd/ofstring.h"      /* for class OFString */
00046 #include "dcmtk/ofstd/ofstream.h"      /* for ostream */
00047 
00048 
00049 /*---------------------*
00050  *  class declaration  *
00051  *---------------------*/
00052 
00055 class OFDate
00056 {
00057     // allow class OFDateTime to access protected class members
00058     friend class OFDateTime;
00059 
00060 
00061  public:
00062 
00066     OFDate();
00067 
00071     OFDate(const OFDate &dateVal);
00072 
00078     OFDate(const unsigned int year,
00079            const unsigned int month,
00080            const unsigned int day);
00081 
00084     virtual ~OFDate();
00085 
00090     virtual OFDate &operator=(const OFDate &dateVal);
00091 
00096     virtual OFBool operator==(const OFDate &dateVal) const;
00097 
00102     virtual OFBool operator!=(const OFDate &dateVal) const;
00103 
00109     virtual OFBool operator<(const OFDate &dateVal) const;
00110 
00116     virtual OFBool operator<=(const OFDate &dateVal) const;
00117 
00123     virtual OFBool operator>=(const OFDate &dateVal) const;
00124 
00130     virtual OFBool operator>(const OFDate &dateVal) const;
00131 
00135     virtual void clear();
00136 
00143     virtual OFBool isValid() const;
00144 
00152     OFBool setDate(const unsigned int year,
00153                    const unsigned int month,
00154                    const unsigned int day);
00155 
00161     OFBool setYear(const unsigned int year);
00162 
00168     OFBool setMonth(const unsigned int month);
00169 
00175     OFBool setDay(const unsigned int day);
00176 
00182     OFBool setCurrentDate();
00183 
00190     OFBool setISOFormattedDate(const OFString &formattedDate);
00191 
00195     unsigned int getYear() const;
00196 
00200     unsigned int getMonth() const;
00201 
00205     unsigned int getDay() const;
00206 
00214     OFBool getISOFormattedDate(OFString &formattedDate,
00215                                const OFBool showDelimiter = OFTrue) const;
00216 
00217     /* --- static helper functions --- */
00218 
00222     static OFDate getCurrentDate();
00223 
00224 
00225  protected:
00226 
00233     OFBool setCurrentDate(const time_t &tt);
00234 
00235     /* --- static helper functions --- */
00236 
00246     static OFBool isDateValid(const unsigned int year,
00247                               const unsigned int month,
00248                               const unsigned int day);
00249 
00250 
00251  private:
00252 
00254     unsigned int Year;
00255 
00257     unsigned int Month;
00258 
00260     unsigned int Day;
00261 };
00262 
00263 
00270 ostream& operator<<(ostream& stream, const OFDate &dateVal);
00271 
00272 
00273 #endif
00274 
00275 
00276 /*
00277  *
00278  * CVS/RCS Log:
00279  * $Log: ofdate.h,v $
00280  * Revision 1.7  2005/12/08 16:05:54  meichel
00281  * Changed include path schema for all DCMTK header files
00282  *
00283  * Revision 1.6  2004/01/16 10:30:39  joergr
00284  * Added setISOFormattedXXX() methods for Date, Time and DateTime.
00285  *
00286  * Revision 1.5  2003/09/15 12:12:56  joergr
00287  * Fixed incorrect/improper comments of the comparision operators. Enhanced
00288  * comment of the default constructor. Made comparison operators const.
00289  *
00290  * Revision 1.4  2003/07/04 13:30:37  meichel
00291  * Added include for ofstream.h, to make sure ofstream is correctly defined
00292  *
00293  * Revision 1.3  2002/05/24 09:43:04  joergr
00294  * Renamed some parameters/variables to avoid ambiguities.
00295  *
00296  * Revision 1.2  2002/04/15 09:38:58  joergr
00297  * Added "include <sys/types.h>" for struct time_t (required for MSVC).
00298  *
00299  * Revision 1.1  2002/04/11 12:12:23  joergr
00300  * Introduced new standard classes providing date and time functions.
00301  *
00302  *
00303  */


Generated on 20 Dec 2005 for OFFIS DCMTK Version 3.5.4 by Doxygen 1.4.5