Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields  

time.Time.h

00001 /*----------------------------------------------------------------------------
00002   SWORD 2000 - Software With Objects for Rapid Development
00003   Copyright (C) 2003 Eric NICOLAS
00004   ----------------------------------------------------------------------------
00005   SWORD is free software; you can redistribute it and/or modify
00006   it under the terms of the GNU Lesser General Public License as published by
00007   the Free Software Foundation; either version 2 of the License, or
00008   (at your option) any later version.
00009 
00010   SWORD is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013   GNU Lesser General Public License for more details.
00014 
00015   You should have received a copy of the GNU Lesser General Public License
00016   along with SWORD; if not, write to the Free Software
00017   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018   --------------------------------------------------------------------------*/
00019 #ifndef _SWORD_TIME_TIME_
00020 #define _SWORD_TIME_TIME_
00021 
00022 #include "sword/time.TimeSpan.h"
00023 #include "sword/base.Comparable.h"
00024 #include "sword/streams.IStream.h"
00025 #include "sword/streams.OStream.h"
00026 
00027 #ifdef POSIX
00028 #  include <time.h>
00029 #  include <sys/timeb.h>
00030 #endif
00031 
00032 
00033 namespace sword {
00034 
00036 
00067         class SWORDDECL Time : public Comparable<Time> {
00068                 public:
00070 
00071                         inline Time() throw();
00072 
00074                         inline Time(int64 value) throw();
00075 
00077                         inline int64 serial() const throw();
00078 
00080                         inline void serial(int64 value) throw();
00081 
00083                         inline int integer1900() const throw();
00084 
00086                         inline Time& integer1900(int value) throw();
00087 
00089                         inline double double1900() const throw();
00090 
00092                         inline Time& double1900(double value) throw();
00093 
00095                         inline bool valid() const throw();
00096 
00098                         inline void invalidate() throw();
00099 
00101                         inline void resetHour() throw();
00102 
00104 
00105                         inline static Time now();
00106 
00108 
00109                         static Time nowUTC();
00110 
00112 
00116                         static TimeSpan timeZone();
00117 
00119                         friend inline TimeSpan operator-(const Time &lhs, const Time &rhs);
00120 
00122                         friend inline Time operator+(const Time &lhs, const TimeSpan &rhs);
00123 
00125                         friend inline Time operator+(const TimeSpan &lhs, const Time &rhs);
00126 
00128                         inline static int compare(const Time &lhs, const Time &rhs);
00129 
00130                         // Round series:
00131                         // new_value = ((old_value + 0.5 * unit) / unit) * unit
00132 
00134                         inline Time& roundDay() throw();
00135 
00137                         inline Time& roundHour() throw();
00138 
00140                         inline Time& roundMinute() throw();
00141 
00143                         inline Time& roundSecond() throw();
00144 
00145                         // Trunc series:
00146                         // new_value = (old_value / unit) * unit
00147 
00149                         inline Time& truncDay() throw();
00150 
00152                         inline Time& truncHour() throw();
00153 
00155                         inline Time& truncMinute() throw();
00156 
00158                         inline Time& truncSecond() throw();
00159 
00161                         friend inline IStream& operator>>(IStream& lhs, Time &rhs);
00162 
00164                         friend inline OStream &operator<<(OStream &lhs, const Time &rhs);
00165 
00166                         // time conversion <-> C Library
00167 
00168                         time_t toC() const;
00169 
00170                         void fromC(time_t value) throw();
00171 
00172 #ifdef POSIX
00173 
00174                         void fromC(struct timeb &value) throw();
00175 
00176 #endif // POSIX
00177 
00178                         // time conversion <-> Win32 FILETIME data type
00179 
00180 #ifdef WIN32
00181 
00182                         FILETIME toFILETIME() const;
00183 
00184                         void fromFILETIME(const FILETIME &valueFILETIME);
00185 
00186 #endif // WIN32
00187 
00188                         class RangeException : public Exception {};
00189 
00190                 private:
00191                         int64 value_;
00192         };
00193 
00194 } // namespace sword
00195 
00196 #include "sword.private/time.Time.inl"
00197 
00198 #endif // _SWORD_TIME_TIME_

Generated on Tue Dec 23 20:08:56 2003 for SWORD by doxygen1.3-rc2