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

  1 mike  1.8 //%/////////////////////////////////////////////////////////////////////////////
  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.8 //
 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.8 
 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.8     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.8 
 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               ATTN: Add inequalities.
 94           */
 95           class PEGASUS_COMMON_LINKAGE CIMDateTime
 96           {
 97           public:
 98           
 99               enum { FORMAT_LENGTH = 25 };
100           
101               /// CIMDateTime CIMMethod
102               CIMDateTime();
103           
104               /** CIMDateTime CIMMethod creates the CIM CIMDateTime from a string 
105           	constant representing the CIM DateTime formatted datetime
106 mike  1.8 	@param str String object containing the CIM DateTime formatted string
107               */
108               CIMDateTime(const char* str);
109           
110               /** CIMDateTime CIMMethod - Creates the CIMDateTime instance from another 
111           	CIMDateTime object
112           	@param x CIMDateTime object to be copied.
113               */
114               CIMDateTime(const CIMDateTime& x);
115           
116               /** Destructor. */
117               ~CIMDateTime() { }
118           
119               /**  assign CIMDateTime
120               */
121               CIMDateTime& operator=(const CIMDateTime& x);
122           
123               /** CIMDateTime isNull method - Tests for an all zero date time
124           	<PRE>
125           	CIMDateTime dt;
126           	dt.clear();
127 mike  1.8     	assert(dt.isNull());
128               	</PRE>
129           	@return This method returns true of the contents are
130           	"00000000000000.000000:000". Else it returns false
131               */
132               Boolean isNull() const;
133           
134               /// method getString
135               const char* getString() const;
136           
137               /** method set - Sets the date time. Creates the CIMDateTime instance from 
138           	the input string constant which must be
139           	in the datetime format.
140           
141           	    <PRE>
142           	    CIMDateTime dt;
143           	    dt.set("19991224120000.000000+360");
144           	    </PRE>
145           
146           	@return On format error, CIMDateTime set throws the exception 
147           	BadDateTimeFormat
148 mike  1.8 	@exception Throws exception BadDateTimeFormat on format error.
149               */
150               void set(const char* str);
151           
152               ///  clear - Clears the datetime class instance.
153               void clear();
154           
155               /** CIMDateTime CIMMethod - ATTN: Friend operator Test for CIMDateTime 
156           	equality
157               */
158               PEGASUS_COMMON_LINKAGE friend Boolean operator==(
159           	const CIMDateTime& x,
160           	const CIMDateTime& y);
161           
162           private:
163           
164               Boolean _set(const char* str);
165               char _rep[FORMAT_LENGTH + 1];
166           };
167           
168           PEGASUS_COMMON_LINKAGE Boolean operator==(
169 mike  1.8     const CIMDateTime& x, 
170               const CIMDateTime& y);
171           
172           PEGASUS_COMMON_LINKAGE PEGASUS_STD(ostream)& operator<<(
173               PEGASUS_STD(ostream)& os, 
174               const CIMDateTime& x);
175           
176           #define PEGASUS_ARRAY_T CIMDateTime
177           # include "ArrayInter.h"
178           #undef PEGASUS_ARRAY_T
179           
180           PEGASUS_NAMESPACE_END
181           
182           #endif /* Pegasus_DateTime_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2