5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
30 $Date: 2009/08/05 11:40:30 $
38 typedef long suseconds_t;
41 struct UTIME: public timeval
55 UTIME(long long a, long long b)
61 bool operator<(const UTIME & rhs) const
63 if (tv_sec < rhs.tv_sec)
65 else if (tv_sec > rhs.tv_sec)
67 else if (tv_usec < rhs.tv_usec)
72 bool operator<=(const UTIME & rhs) const
74 if (tv_sec < rhs.tv_sec)
76 else if (tv_sec > rhs.tv_sec)
78 else if (tv_usec < rhs.tv_usec)
80 else if (tv_usec > rhs.tv_usec)
85 bool operator>(const UTIME & rhs) const
87 if (tv_sec > rhs.tv_sec)
89 else if (tv_sec < rhs.tv_sec)
91 else if (tv_usec > rhs.tv_usec)
96 bool operator>=(const UTIME & rhs) const
98 if (tv_sec > rhs.tv_sec)
100 else if (tv_sec < rhs.tv_sec)
102 else if (tv_usec > rhs.tv_usec)
104 else if (tv_usec < rhs.tv_usec)
109 bool operator==(const UTIME & rhs) const
111 //cout << tv_sec << "." << tv_usec << " " << rhs.tv_sec << "." << rhs.tv_usec << endl;
112 //cout << (tv_sec == rhs.tv_sec) << " " << (tv_usec == rhs.tv_usec) << endl;
113 return (tv_sec == rhs.tv_sec) && (tv_usec == rhs.tv_usec);
116 UTIME operator+(const UTIME & rhs)
120 /*a = tv_sec * 1000000 + tv_usec;
121 b = rhs.tv_sec * 1000000 + rhs.tv_usec;
122 return UTIME((a + b) / 1000000, (a + b) % 1000000);*/
123 a = tv_sec + rhs.tv_sec;
124 b = tv_usec + rhs.tv_usec;
133 UTIME operator-(const UTIME & rhs)
137 /*a = tv_sec * 1000000 + tv_usec;
138 b = rhs.tv_sec * 1000000 + rhs.tv_usec;
139 return UTIME((a - b) / 1000000, (a - b) % 1000000);*/
140 a = tv_sec - rhs.tv_sec;
141 b = tv_usec - rhs.tv_usec;
150 return UTIME(--a, b + 1000000);
157 return UTIME(++a, 1000000 - b);
166 time_t GetSec() const
171 suseconds_t GetUSec() const