00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
00131
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
00146
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
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
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 }
00195
00196 #include "sword.private/time.Time.inl"
00197
00198 #endif // _SWORD_TIME_TIME_