mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Date::Compare
git-svn-id: svn://ultimatepp.org/upp/trunk@597 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
30574be501
commit
284f3e26cb
2 changed files with 11 additions and 5 deletions
|
|
@ -230,12 +230,16 @@ void Date::Set(int d) {
|
|||
day = d + 1;
|
||||
}
|
||||
|
||||
int Date::Compare(Date b) const
|
||||
{
|
||||
int q = SgnCompare(year, b.year);
|
||||
if(q) return q;
|
||||
q = SgnCompare(month, b.month);
|
||||
return q ? q : SgnCompare(day, b.day);
|
||||
}
|
||||
|
||||
bool operator<(Date a, Date b) {
|
||||
if(a.year < b.year) return true;
|
||||
if(a.year > b.year) return false;
|
||||
if(a.month < b.month) return true;
|
||||
if(a.month > b.month) return false;
|
||||
return a.day < b.day;
|
||||
return a.Compare(b) < 0;
|
||||
}
|
||||
|
||||
int operator-(Date a, Date b) { return a.Get() - b.Get(); }
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ struct Date : RelOps< Date, Moveable<Date> > {
|
|||
|
||||
static Date Low() { return Date(-4000, 1, 1); }
|
||||
static Date High() { return Date(4000, 1, 1); }
|
||||
|
||||
int Compare(Date b) const;
|
||||
|
||||
Date() { year = -32768; day = month = 0; }
|
||||
Date(const Nuller&) { year = -32768; day = month = 0; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue