(file) Return to CIMDateTime.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  1 mike  1.10 //%/////////////////////////////////////////////////////////////////////////////
  2            //
  3            // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
  4            //
  5            // Permission is hereby granted, free of charge, to any person obtaining a copy
  6            // of this software and associated documentation files (the "Software"), to 
  7            // deal in the Software without restriction, including without limitation the 
  8            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 
  9            // sell copies of the Software, and to permit persons to whom the Software is
 10            // furnished to do so, subject to the following conditions:
 11            // 
 12            // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN 
 13            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 14            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 15            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
 16            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
 17            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
 18            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 19            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 20            //
 21            //==============================================================================
 22 mike  1.10 //
 23            // Author: Mike Brasher (mbrasher@bmc.com)
 24            //
 25            // Modified By:
 26            //
 27            //%/////////////////////////////////////////////////////////////////////////////
 28            
 29            #ifndef Pegasus_DateTime_h
 30            #define Pegasus_DateTime_h
 31            
 32            #include <Pegasus/Common/Config.h>
 33            #include <Pegasus/Common/Array.h>
 34            #include <iostream>
 35            
 36            PEGASUS_NAMESPACE_BEGIN
 37            
 38            /**
 39                The CIMDateTime class represents the CIM datetime data type as a C++ class 
 40                CIMDateTime. A CIM datetime may contain a date or an interval. CIMDateTime 
 41                is an intrinsic CIM data type which represents the time as a formated 
 42                fixedplength string.
 43 mike  1.10 
 44                <PRE>
 45                A date has the following form:
 46            	yyyymmddhhmmss.mmmmmmsutc
 47            
 48                Where
 49            
 50            	yyyy = year (0-1999)
 51            	mm = month (1-12)
 52            	dd = day (1-31)
 53            	hh = hour (0-23)
 54            	mm = minute (0-59)
 55            	ss = second (0-59)
 56            	mmmmmm = microseconds.
 57            	s = '+' or '-' to represent the UTC sign.
 58            	utc = UTC offset (same as GMT offset).
 59            
 60                An interval has the following form:
 61            
 62            	ddddddddhhmmss.mmmmmm:000
 63            
 64 mike  1.10     Where
 65            
 66            	dddddddd = days
 67            	hh = hours
 68            	mm = minutes
 69            	ss = seconds
 70            	mmmmmm = microseconds
 71                </PRE>
 72            
 73                Note that intervals always end in ":000" (this is how they
 74                are distinguished from dates).
 75            
 76                Intervals are really durations since they do not specify a start and
 77                end time (as one expects when speaking about an interval). It is
 78                better to think of an interval as specifying time elapsed since
 79                some event.
 80            
 81                CIMDateTime objects are constructed from C character strings or from
 82                other CIMDateTime objects. These character strings must be exactly
 83                twenty-five characters and conform to one of the forms idententified
 84                above.
 85 mike  1.10 
 86                CIMDateTime objects which are not explicitly initialized will be
 87                implicitly initialized with the null time interval:
 88            
 89            	00000000000000.000000:000
 90            
 91                Instances can be tested for nullness with the isNull() method.
 92            */
 93            class PEGASUS_COMMON_LINKAGE CIMDateTime
 94            {
 95            public:
 96            
 97                enum { FORMAT_LENGTH = 25 };
 98            
 99                /// CIMDateTime CIMMethod
100                CIMDateTime();
101            
102                /** CIMDateTime CIMMethod creates the CIM CIMDateTime from a string 
103            	constant representing the CIM DateTime formatted datetime
104            	@param str String object containing the CIM DateTime formatted string
105                */
106 mike  1.10     CIMDateTime(const char* str);
107            
108                /** CIMDateTime CIMMethod - Creates the CIMDateTime instance from another 
109            	CIMDateTime object
110            	@param x CIMDateTime object to be copied.
111                */
112                CIMDateTime(const CIMDateTime& x);
113            
114                /** Destructor. */
115                ~CIMDateTime() { }
116            
117                /**  assign CIMDateTime
118                */
119                CIMDateTime& operator=(const CIMDateTime& x);
120            
121                /** CIMDateTime isNull method - Tests for an all zero date time
122            	<PRE>
123            	CIMDateTime dt;
124            	dt.clear();
125                	assert(dt.isNull());
126                	</PRE>
127 mike  1.10 	@return This method returns true of the contents are
128            	"00000000000000.000000:000". Else it returns false
129                */
130                Boolean isNull() const;
131            
132                /// method getString
133                const char* getString() const;
134            
135                /** method set - Sets the date time. Creates the CIMDateTime instance from 
136            	the input string constant which must be
137            	in the datetime format.
138            
139            	    <PRE>
140            	    CIMDateTime dt;
141            	    dt.set("19991224120000.000000+360");
142            	    </PRE>
143            
144            	@return On format error, CIMDateTime set throws the exception 
145            	BadDateTimeFormat
146            	@exception Throws exception BadDateTimeFormat on format error.
147                */
148 mike  1.10     void set(const char* str);
149            
150                ///  clear - Clears the datetime class instance.
151                void clear();
152            
153                /** CIMDateTime CIMMethod - ATTN: Friend operator Test for CIMDateTime 
154            	equality
155                */
156                PEGASUS_COMMON_LINKAGE friend Boolean operator==(
157            	const CIMDateTime& x,
158            	const CIMDateTime& y);
159            
160            private:
161            
162                Boolean _set(const char* str);
163                char _rep[FORMAT_LENGTH + 1];
164            };
165            
166            PEGASUS_COMMON_LINKAGE Boolean operator==(
167                const CIMDateTime& x, 
168                const CIMDateTime& y);
169 mike  1.10 
170            PEGASUS_COMMON_LINKAGE PEGASUS_STD(ostream)& operator<<(
171                PEGASUS_STD(ostream)& os, 
172                const CIMDateTime& x);
173            
174            #define PEGASUS_ARRAY_T CIMDateTime
175            # include "ArrayInter.h"
176            #undef PEGASUS_ARRAY_T
177            
178            PEGASUS_NAMESPACE_END
179            
180            #endif /* Pegasus_DateTime_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2