#include <OSGDate.h>
Public Member Functions | |
Constructors | |
| Date (void) | |
| Date (const Date &obj) | |
Destructors | |
| virtual | ~Date (void) |
Access | |
| void | setSecond (UInt32 second) |
| UInt32 | getSecond (void) |
| void | setMinute (UInt32 minute) |
| UInt32 | getMinute (void) |
| void | setHour (UInt32 hour) |
| UInt32 | getHour (void) |
| void | setDay (UInt32 day) |
| UInt32 | getDay (void) |
| void | setYear (Int32 year) |
| Int32 | getYear (void) |
| void | clear (void) |
| void | setSystemDate (void) |
| void | set (const Char8 *stringP) |
| bool | isLeapYear (void) |
| bool | valid (void) |
| void | set (UInt32 day, UInt32 month, Int32 year, UInt32 hour=0, UInt32 minute=0, UInt32 second=0) |
Operators | |
| bool | operator== (const Date &other) |
| bool | operator!= (const Date &other) |
| bool | operator< (const Date &other) |
Private Attributes | |
| UInt32 | _second |
| UInt32 | _minute |
| UInt32 | _hour |
| UInt32 | _day |
| UInt32 | _month |
| UInt32 | _year |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Date &obj) |
| std::istream & | operator>> (std::istream &is, Date &obj) |
Definition at line 53 of file OSGDate.h.
| Date::Date | ( | void | ) |
| Date::Date | ( | const Date & | obj | ) |
| Date::~Date | ( | void | ) | [virtual] |
| void OSG::Date::setSecond | ( | UInt32 | second | ) | [inline] |
Definition at line 48 of file OSGDate.inl.
References _second.
00049 { 00050 _second = second; 00051 }
| UInt32 OSG::Date::getSecond | ( | void | ) | [inline] |
| void OSG::Date::setMinute | ( | UInt32 | minute | ) | [inline] |
Definition at line 62 of file OSGDate.inl.
References _minute.
00063 { 00064 _minute = minute; 00065 }
| UInt32 OSG::Date::getMinute | ( | void | ) | [inline] |
| void OSG::Date::setHour | ( | UInt32 | hour | ) | [inline] |
| UInt32 OSG::Date::getHour | ( | void | ) | [inline] |
| void OSG::Date::setDay | ( | UInt32 | day | ) | [inline] |
| UInt32 OSG::Date::getDay | ( | void | ) | [inline] |
| void OSG::Date::setYear | ( | Int32 | year | ) | [inline] |
| Int32 OSG::Date::getYear | ( | void | ) | [inline] |
| void OSG::Date::clear | ( | void | ) |
| void Date::setSystemDate | ( | void | ) |
Definition at line 76 of file OSGDate.cpp.
References _day, _hour, _minute, _month, _second, and _year.
00077 { 00078 time_t clock; 00079 struct tm *tm_time; 00080 00081 time(&clock); 00082 00083 tm_time = localtime(&clock); 00084 00085 _second = tm_time->tm_sec; 00086 _minute = tm_time->tm_min; 00087 _hour = tm_time->tm_hour; 00088 _day = tm_time->tm_mday; 00089 _month = tm_time->tm_mon + 1; 00090 _year = tm_time->tm_year + 1900; 00091 }
| void Date::set | ( | const Char8 * | stringP | ) |
Definition at line 94 of file OSGDate.cpp.
00095 { 00096 if(stringP != NULL&& *stringP != '\0') 00097 { 00098 // istrstream is(string); 00099 // is >> *this; 00100 } 00101 }
| bool Date::isLeapYear | ( | void | ) |
Definition at line 104 of file OSGDate.cpp.
References _year.
Referenced by valid().
00105 { 00106 if(_year & 3) 00107 { 00108 return false; 00109 } 00110 00111 if((_year % 100) || !(_year % 400)) 00112 { 00113 return true; 00114 } 00115 00116 return false; 00117 }
| bool Date::valid | ( | void | ) |
Definition at line 120 of file OSGDate.cpp.
References _day, _hour, _minute, _month, _second, and isLeapYear().
00121 { 00122 static const UInt32 daysPerMonth[12] = 00123 { 00124 31, 28, 31, 30, 31, 30, 30, 31, 30, 31, 30, 31 00125 }; 00126 00127 if((_hour > 23) || (_minute > 59) || (_second > 59)) 00128 { 00129 return false; 00130 } 00131 00132 if((_month < 1) || (_day < 1) || (_month > 12)) 00133 { 00134 return false; 00135 } 00136 00137 if(_day <= daysPerMonth[_month - 1]) 00138 { 00139 return true; 00140 } 00141 00142 if((_month == 2) && (_day == 29)) 00143 { 00144 return isLeapYear(); 00145 } 00146 00147 return false; 00148 }
| void Date::set | ( | UInt32 | day, | |
| UInt32 | month, | |||
| Int32 | year, | |||
| UInt32 | hour = 0, |
|||
| UInt32 | minute = 0, |
|||
| UInt32 | second = 0 | |||
| ) |
| bool Date::operator== | ( | const Date & | other | ) |
Definition at line 167 of file OSGDate.cpp.
References _day, _hour, _minute, _month, _second, and _year.
00168 { 00169 return ((_day == other._day ) && 00170 (_month == other._month ) && 00171 (_year == other._year ) && 00172 (_hour == other._hour ) && 00173 (_minute == other._minute) && 00174 (_second == other._second) ); 00175 }
| bool OSG::Date::operator!= | ( | const Date & | other | ) | [inline] |
| bool Date::operator< | ( | const Date & | other | ) |
Definition at line 178 of file OSGDate.cpp.
References _day, _hour, _minute, _month, _second, and _year.
00179 { 00180 if(_year < other._year) 00181 return true; 00182 00183 if(_year > other._year) 00184 return false; 00185 00186 // _year == other._year 00187 00188 if(_month < other._month) 00189 return true; 00190 00191 if(_month > other._month) 00192 return false; 00193 00194 // _month == other._month 00195 00196 if(_day < other._day) 00197 return true; 00198 if(_day > other._day) 00199 return false; 00200 00201 // _day == other._day 00202 00203 if(_hour < other._hour) 00204 return true; 00205 if(_hour > other._hour) 00206 return false; 00207 00208 // _hour == other._hour 00209 00210 if(_minute < other._minute) 00211 return true; 00212 if(_minute > other._minute) 00213 return false; 00214 00215 // _minute == other._minute 00216 00217 if(_second < other._second) 00218 return true; 00219 00220 return false; 00221 }
| std::ostream& operator<< | ( | std::ostream & | os, | |
| const Date & | obj | |||
| ) | [friend] |
Definition at line 224 of file OSGDate.cpp.
00225 { 00226 return outStream << std::setfill('0') 00227 << std::setw(2) << obj._day << '.' 00228 << std::setw(2) << obj._month << '.' 00229 << obj._year << ' ' 00230 << std::setw(2) << obj._hour << ':' 00231 << std::setw(2) << obj._minute << ':' 00232 << std::setw(2) << obj._second; 00233 }
| std::istream& operator>> | ( | std::istream & | is, | |
| Date & | obj | |||
| ) | [friend] |
UInt32 OSG::Date::_second [private] |
Definition at line 121 of file OSGDate.h.
Referenced by getSecond(), operator<(), operator==(), set(), setSecond(), setSystemDate(), and valid().
UInt32 OSG::Date::_minute [private] |
Definition at line 122 of file OSGDate.h.
Referenced by getMinute(), operator<(), operator==(), set(), setMinute(), setSystemDate(), and valid().
UInt32 OSG::Date::_hour [private] |
Definition at line 123 of file OSGDate.h.
Referenced by getHour(), operator<(), operator==(), set(), setHour(), setSystemDate(), and valid().
UInt32 OSG::Date::_day [private] |
Definition at line 124 of file OSGDate.h.
Referenced by getDay(), operator<(), operator==(), set(), setDay(), setSystemDate(), and valid().
UInt32 OSG::Date::_month [private] |
Definition at line 125 of file OSGDate.h.
Referenced by operator<(), operator==(), set(), setSystemDate(), and valid().
UInt32 OSG::Date::_year [private] |
Definition at line 126 of file OSGDate.h.
Referenced by getYear(), isLeapYear(), operator<(), operator==(), set(), setSystemDate(), and setYear().