OTime.cc

Go to the documentation of this file.
00001 /*
00002  * This file is part of openSDK.
00003  *
00004  * Copyright (C) 2006-2007 openSDK team
00005  *
00006  * openSDK is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; version 2.
00009  *
00010  * openSDK 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 General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with openSDK; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  *
00019  *     $Id: OTime.cc,v 1.5 2007/01/26 23:12:05 nuno-lopes Exp $
00020  */
00021 
00022 #include <OPENR/OTime.h>
00023 
00024 OTime::OTime()
00025 {
00026         clock_ = 0;
00027         timeDif_ = 0;
00028 }
00029 
00030 OTime::OTime(time_t clock, sbyte timeDif)
00031 {
00032         clock_ = clock;
00033         timeDif_ = timeDif;
00034 }
00035 
00036 OTime::OTime(const OTime& time)
00037 {
00038         *this = time;
00039 }
00040 
00041 OTime& OTime::operator=(const OTime& time)
00042 {
00043         clock_ = time.clock_;
00044         timeDif_ = time.timeDif_;
00045         return *this;
00046 }
00047 
00048 bool OTime::operator<(const OTime& time) const
00049 {
00050         return (clock_ < time.clock_);
00051 }
00052 
00053 bool OTime::operator<=(const OTime& time) const
00054 {
00055         return (clock_ <= time.clock_);
00056 }
00057 
00058 bool OTime::operator>(const OTime& time) const
00059 {
00060         return (clock_ > time.clock_);
00061 }
00062 
00063 bool OTime::operator>=(const OTime& time) const
00064 {
00065         return (clock_ >= time.clock_);
00066 }
00067 
00068 bool OTime::operator==(const OTime& time) const
00069 {
00070         return (clock_ == time.clock_);
00071 }
00072 
00073 OStatus OTime::Set(time_t clock, sbyte timeDif)
00074 {
00075         clock_ = clock;
00076         timeDif_ = timeDif;
00077         return oSUCCESS;
00078 }
00079 
00080 OStatus OTime::SetClock(time_t clock)
00081 {
00082         clock_ = clock;
00083         return oSUCCESS;
00084 }
00085 
00086 OStatus OTime::SetLocalTime(time_t localTime)
00087 {
00088         clock_ = localTime - (timeDif_ * 3600);
00089         return oSUCCESS;
00090 }
00091 
00092 OStatus OTime::SetTimeDif(sbyte timeDif)
00093 {
00094         timeDif_ = timeDif;
00095         return oSUCCESS;
00096 }
00097 
00098 time_t OTime::GetClock() const
00099 {
00100         return clock_;
00101 }
00102 
00103 time_t OTime::GetLocalTime() const
00104 {
00105         // time diff represents the time offset (-12 to 12)
00106         return clock_ + (timeDif_ * 3600);
00107 }
00108 
00109 sbyte OTime::GetTimeDif() const
00110 {
00111         return timeDif_;
00112 }

Generated on Sun Dec 2 23:04:30 2007 for openSDK by  doxygen 1.3.9.1