00001 /* 00002 * RawDateTime.hpp 00003 * 00004 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. 00005 * 00006 * Oracle is a registered trademarks of Oracle Corporation and/or its 00007 * affiliates. 00008 * 00009 * This software is the confidential and proprietary information of Oracle 00010 * Corporation. You shall not disclose such confidential and proprietary 00011 * information and shall use it only in accordance with the terms of the 00012 * license agreement you entered into with Oracle. 00013 * 00014 * This notice may not be removed or altered. 00015 */ 00016 #ifndef COH_RAW_DATE_TIME_HPP 00017 #define COH_RAW_DATE_TIME_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/io/pof/RawDate.hpp" 00022 #include "coherence/io/pof/RawTime.hpp" 00023 00024 #include <ostream> 00025 #include <time.h> 00026 00027 COH_OPEN_NAMESPACE3(coherence,io,pof) 00028 00029 00030 /** 00031 * Raw immutable POF date-time value. 00032 * 00033 * @author jh 2008.04.08 00034 */ 00035 class COH_EXPORT RawDateTime 00036 : public cloneable_spec<RawDateTime> 00037 { 00038 friend class factory<RawDateTime>; 00039 00040 // ----- typedefs ------------------------------------------------------- 00041 00042 public: 00043 /** 00044 * The boxed native type. 00045 */ 00046 typedef struct tm BoxedType; 00047 00048 00049 // ----- constructors --------------------------------------------------- 00050 00051 protected: 00052 /** 00053 * Construct a date-time value. 00054 * 00055 * @param vDate the date portion of the raw date-time value 00056 * @param vTime the time portion of the raw date-time value 00057 * 00058 * @return the new RawDateTime 00059 */ 00060 RawDateTime(RawDate::View vDate, RawTime::View vTime); 00061 00062 /** 00063 * Construct a raw POF datetime value from a POSIX datetime struct. 00064 * 00065 * Note that the POSIX daylight savings flag is not preserved. 00066 * 00067 * @param timeinfo the POSIX datetime 00068 * @param fUTC true if the time value is UTC or false if the time 00069 * value does not have an explicit time zone 00070 * 00071 */ 00072 RawDateTime(const struct tm& timeinfo, bool fUTC = false); 00073 00074 /** 00075 * Copy constructor. 00076 */ 00077 RawDateTime(const RawDateTime& that); 00078 00079 00080 // ----- Object interface ----------------------------------------------- 00081 00082 public: 00083 /** 00084 * {@inheritDoc} 00085 */ 00086 virtual bool equals(Object::View v) const; 00087 00088 /** 00089 * {@inheritDoc} 00090 */ 00091 virtual size32_t hashCode() const; 00092 00093 /** 00094 * {@inheritDoc} 00095 */ 00096 virtual bool isImmutable() const; 00097 00098 /** 00099 * {@inheritDoc} 00100 */ 00101 virtual void toStream(std::ostream &out) const; 00102 00103 00104 // ----- accessors ------------------------------------------------------ 00105 00106 public: 00107 /** 00108 * Obtain the date portion of the raw date-time value. 00109 * 00110 * @return the date portion of the raw date-time value 00111 */ 00112 virtual RawDate::View getRawDate() const; 00113 00114 /** 00115 * Obtain the time portion of the raw date-time value. 00116 * 00117 * @return the time portion of the raw date-time value 00118 */ 00119 virtual RawTime::View getRawTime() const; 00120 00121 /** 00122 * Convert the RawDateTime to a POSIX datetime struct. 00123 * 00124 * Note that RawTime's nanosecond and timezone related information are 00125 * not preserved. 00126 */ 00127 virtual operator struct tm() const; 00128 00129 00130 // ----- data members --------------------------------------------------- 00131 00132 protected: 00133 /** 00134 * The date portion of the raw date-time value. 00135 */ 00136 FinalView<RawDate> f_vDate; 00137 00138 /** 00139 * The time portion of the raw date-time value. 00140 */ 00141 FinalView<RawTime> f_vTime; 00142 }; 00143 00144 COH_CLOSE_NAMESPACE3 00145 00146 #endif // COH_RAW_DATE_TIME_HPP