C++ Client API Reference for Oracle Coherence
14c (14.1.2.0.0)

F79659-03

coherence/io/pof/RawTime.hpp

00001 /*
00002  * Copyright (c) 2000, 2020, Oracle and/or its affiliates.
00003  *
00004  * Licensed under the Universal Permissive License v 1.0 as shown at
00005  * http://oss.oracle.com/licenses/upl.
00006  */
00007 #ifndef COH_RAW_TIME_HPP
00008 #define COH_RAW_TIME_HPP
00009 
00010 #include "coherence/lang.ns"
00011 
00012 #include "coherence/io/pof/PofIntrinsic.hpp"
00013 
00014 
00015 #include <time.h>
00016 
00017 COH_OPEN_NAMESPACE3(coherence,io,pof)
00018 
00019 
00020 /**
00021 * Raw immutable POF time value.
00022 *
00023 * @author jh  2008.04.08
00024 */
00025 class COH_EXPORT RawTime
00026     : public cloneable_spec<RawTime,
00027           extends<Object>,
00028           implements<PofIntrinsic> >
00029     {
00030     friend class factory<RawTime>;
00031 
00032     // ----- typedefs -------------------------------------------------------
00033 
00034     public:
00035         /**
00036         * The boxed native type.
00037         */
00038         typedef struct tm BoxedType;
00039 
00040 
00041     // ----- constructors ---------------------------------------------------
00042 
00043     protected:
00044         /**
00045         * Construct a raw POF time value.
00046         *
00047         * @param nHour   the hour between 0 and 23 inclusive
00048         * @param nMinute the minute value between 0 and 59 inclusive
00049         * @param nSecond the second value between 0 and 59 inclusive (and
00050         *                theoretically 60 for a leap-second)
00051         * @param nNano   the nanosecond value between 0 and 999999999
00052         *                inclusive
00053         * @param fUTC    true if the time value is UTC or false if the time
00054         *                value does not have an explicit time zone
00055         */
00056         RawTime(int32_t nHour, int32_t nMinute, int32_t nSecond,
00057                 int32_t nNano, bool fUTC);
00058 
00059         /**
00060         * Construct a raw POF time value with a timezone.
00061         *
00062         * @param nHour          the hour between 0 and 23 inclusive
00063         * @param nMinute        the minute value between 0 and 59 inclusive
00064         * @param nSecond        the second value between 0 and 59 inclusive
00065         *                       (and theoretically 60 for a leap-second)
00066         * @param nNano          the nanosecond value between 0 and 999999999
00067         *                       inclusive
00068         * @param nHourOffset    the timezone offset in hours from UTC, for
00069         *                       example 0 for BST, -5 for EST and 1 for CET
00070         * @param nMinuteOffset  the timezone offset in minutes, for example 0
00071         *                       (in most cases) or 30
00072         */
00073         RawTime(int32_t nHour, int32_t nMinute, int32_t nSecond,
00074                 int32_t nNano, int32_t nHourOffset, int32_t nMinuteOffset);
00075 
00076         /**
00077         * Construct a raw POF time value from a POSIX datetime struct.
00078         *
00079         * Note that the POSIX daylight savings flag is not preserved.
00080         *
00081         * @param timeinfo  the POSIX time
00082         * @param fUTC      true if the time value is UTC or false if the time
00083         *                  value does not have an explicit time zone
00084         */
00085         RawTime(const struct tm& timeinfo, bool fUTC = false);
00086 
00087         /**
00088         * Copy constructor.
00089         */
00090         RawTime(const RawTime& that);
00091 
00092 
00093     // ----- Object interface -----------------------------------------------
00094 
00095     public:
00096         /**
00097         * {@inheritDoc}
00098         */
00099         virtual bool equals(Object::View v) const;
00100 
00101         /**
00102         * {@inheritDoc}
00103         */
00104         virtual size32_t hashCode() const;
00105 
00106         /**
00107         * {@inheritDoc}
00108         */
00109         virtual bool isImmutable() const;
00110 
00111         /**
00112         * {@inheritDoc}
00113         */
00114         virtual TypedHandle<const String> toString() const;
00115 
00116 
00117     // ----- accessors ------------------------------------------------------
00118 
00119     public:
00120         /**
00121         * Determine the time's hour value.
00122         *
00123         * @return the hour between 0 and 23 inclusive
00124         */
00125         virtual int32_t getHour() const;
00126 
00127         /**
00128         * Determine the time's minute value.
00129         *
00130         * @return the minute value between 0 and 59 inclusive
00131         */
00132         virtual int32_t getMinute() const;
00133 
00134         /**
00135         * Determine the time's second value.
00136         *
00137         * @return the second value between 0 and 59 inclusive (and possibly
00138         *         60 for a leap-second)
00139         */
00140         virtual int32_t getSecond() const;
00141 
00142         /**
00143         * Determine the time's nanosecond value.
00144         *
00145         * @return the nanosecond value between 0 and 999999999 inclusive
00146         */
00147         virtual int32_t getNano() const;
00148 
00149         /**
00150         * Determine if the time value has an explicit timezone. A time value
00151         * without an explicit timezone is assumed to be in some conventional
00152         * local timezone, according to ISO8601.
00153         *
00154         * @return true iff the time has an explicit timezone
00155         */
00156         virtual bool hasTimezone() const;
00157 
00158         /**
00159         * Determine if the time value uses UTC.
00160         *
00161         * @return true if the time value is a UTC value
00162         */
00163         virtual bool isUTC() const;
00164 
00165         /**
00166         * Determine the timezone's hour offset value.
00167         *
00168         * @return the hour offset of the timezeone, or zero if there is no
00169         *         explicit timezone or the time is UTC
00170         */
00171         virtual int32_t getHourOffset() const;
00172 
00173         /**
00174         * Determine the timezone's minute offset value.
00175         *
00176         * @return the minute offset of the timezeone, or zero if there is no
00177         *         explicit timezone or the time is UTC
00178         */
00179         virtual int32_t getMinuteOffset() const;
00180 
00181         /**
00182         * Convert the RawTime to a POSIX datetime struct.
00183         *
00184         * Note that the nanosecond and timezone related information are not
00185         * preserved.
00186         *
00187         */
00188         virtual operator struct tm() const;
00189 
00190 
00191     // ----- data members ---------------------------------------------------
00192 
00193     protected:
00194         /**
00195         * The hour number.
00196         */
00197         int32_t m_nHour;
00198 
00199         /**
00200         * The minute number.
00201         */
00202         int32_t m_nMinute;
00203 
00204         /**
00205         * The second number.
00206         */
00207         int32_t m_nSecond;
00208 
00209         /**
00210         * The nanosecond number.
00211         */
00212         int32_t m_nNano;
00213 
00214         /**
00215         * The timezone indicator, one of the TZ_ enumerated constants.
00216         */
00217         int32_t m_nTimeZoneType;
00218 
00219         /**
00220         * The hour offset of the time's timezone.
00221         */
00222         int32_t m_nHourOffset;
00223 
00224         /**
00225         * The minute offset of the time's timezone.
00226         */
00227         int32_t m_nMinuteOffset;
00228     };
00229 
00230 COH_CLOSE_NAMESPACE3
00231 
00232 #endif // COH_RAW_TIME_HPP
Copyright © 2000, 2025, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.