00001 /* 00002 * RawTime.hpp 00003 * 00004 * Copyright 2001-2008 by Oracle. 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_TIME_HPP 00017 #define COH_RAW_TIME_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include <ostream> 00022 00023 COH_OPEN_NAMESPACE3(coherence,io,pof) 00024 00025 00026 /** 00027 * Raw immutable POF time value. 00028 * 00029 * @author jh 2008.04.08 00030 */ 00031 class COH_EXPORT RawTime 00032 : public cloneable_spec<RawTime> 00033 { 00034 friend class factory<RawTime>; 00035 00036 // ----- constructors --------------------------------------------------- 00037 00038 protected: 00039 /** 00040 * Construct a raw POF time value. 00041 * 00042 * @param nHour the hour between 0 and 23 inclusive 00043 * @param nMinute the minute value between 0 and 59 inclusive 00044 * @param nSecond the second value between 0 and 59 inclusive (and 00045 * theoretically 60 for a leap-second) 00046 * @param nNano the nanosecond value between 0 and 999999999 00047 * inclusive 00048 * @param fUTC true if the time value is UTC or false if the time 00049 * value does not have an explicit time zone 00050 */ 00051 RawTime(int32_t nHour, int32_t nMinute, int32_t nSecond, 00052 int32_t nNano, bool fUTC); 00053 00054 /** 00055 * Construct a raw POF time value with a timezone. 00056 * 00057 * @param nHour the hour between 0 and 23 inclusive 00058 * @param nMinute the minute value between 0 and 59 inclusive 00059 * @param nSecond the second value between 0 and 59 inclusive 00060 * (and theoretically 60 for a leap-second) 00061 * @param nNano the nanosecond value between 0 and 999999999 00062 * inclusive 00063 * @param nHourOffset the timezone offset in hours from UTC, for 00064 * example 0 for BST, -5 for EST and 1 for CET 00065 * @param nMinuteOffset the timezone offset in minutes, for example 0 00066 * (in most cases) or 30 00067 */ 00068 RawTime(int32_t nHour, int32_t nMinute, int32_t nSecond, 00069 int32_t nNano, int32_t nHourOffset, int32_t nMinuteOffset); 00070 00071 /** 00072 * Copy constructor. 00073 */ 00074 RawTime(const RawTime& that); 00075 00076 00077 // ----- Object interface ----------------------------------------------- 00078 00079 public: 00080 /** 00081 * {@inheritDoc} 00082 */ 00083 virtual bool equals(Object::View v) const; 00084 00085 /** 00086 * {@inheritDoc} 00087 */ 00088 virtual size32_t hashCode() const; 00089 00090 /** 00091 * {@inheritDoc} 00092 */ 00093 virtual bool isImmutable() const; 00094 00095 /** 00096 * {@inheritDoc} 00097 */ 00098 virtual void toStream(std::ostream &out) const; 00099 00100 00101 // ----- accessors ------------------------------------------------------ 00102 00103 public: 00104 /** 00105 * Determine the time's hour value. 00106 * 00107 * @return the hour between 0 and 23 inclusive 00108 */ 00109 virtual int32_t getHour() const; 00110 00111 /** 00112 * Determine the time's minute value. 00113 * 00114 * @return the minute value between 0 and 59 inclusive 00115 */ 00116 virtual int32_t getMinute() const; 00117 00118 /** 00119 * Determine the time's second value. 00120 * 00121 * @return the second value between 0 and 59 inclusive (and possibly 00122 * 60 for a leap-second) 00123 */ 00124 virtual int32_t getSecond() const; 00125 00126 /** 00127 * Determine the time's nanosecond value. 00128 * 00129 * @return the nanosecond value between 0 and 999999999 inclusive 00130 */ 00131 virtual int32_t getNano() const; 00132 00133 /** 00134 * Determine if the time value has an explicit timezone. A time value 00135 * without an explicit timezone is assumed to be in some conventional 00136 * local timezone, according to ISO8601. 00137 * 00138 * @return true iff the time has an explicit timezone 00139 */ 00140 virtual bool hasTimezone() const; 00141 00142 /** 00143 * Determine if the time value uses UTC. 00144 * 00145 * @return true if the time value is a UTC value 00146 */ 00147 virtual bool isUTC() const; 00148 00149 /** 00150 * Determine the timezone's hour offset value. 00151 * 00152 * @return the hour offset of the timezeone, or zero if there is no 00153 * explicit timezone or the time is UTC 00154 */ 00155 virtual int32_t getHourOffset() const; 00156 00157 /** 00158 * Determine the timezone's minute offset value. 00159 * 00160 * @return the minute offset of the timezeone, or zero if there is no 00161 * explicit timezone or the time is UTC 00162 */ 00163 virtual int32_t getMinuteOffset() const; 00164 00165 00166 // ----- data members --------------------------------------------------- 00167 00168 protected: 00169 /** 00170 * The hour number. 00171 */ 00172 int32_t m_nHour; 00173 00174 /** 00175 * The minute number. 00176 */ 00177 int32_t m_nMinute; 00178 00179 /** 00180 * The second number. 00181 */ 00182 int32_t m_nSecond; 00183 00184 /** 00185 * The nanosecond number. 00186 */ 00187 int32_t m_nNano; 00188 00189 /** 00190 * The timezone indicator, one of the TZ_ enumerated constants. 00191 */ 00192 int32_t m_nTimeZoneType; 00193 00194 /** 00195 * The hour offset of the time's timezone. 00196 */ 00197 int32_t m_nHourOffset; 00198 00199 /** 00200 * The minute offset of the time's timezone. 00201 */ 00202 int32_t m_nMinuteOffset; 00203 }; 00204 00205 COH_CLOSE_NAMESPACE3 00206 00207 #endif // COH_RAW_TIME_HPP