Core: Date now has operator++/--

git-svn-id: svn://ultimatepp.org/upp/trunk@4382 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2012-01-09 15:59:33 +00:00
parent 0bbd5db7c7
commit 123187cd18
2 changed files with 11 additions and 0 deletions

View file

@ -18,6 +18,9 @@ struct Date : RelOps< Date, Moveable<Date> > {
int Compare(Date b) const;
Date& operator++() { if(day < 28) day++; else Set(Get() + 1); return *this; }
Date& operator--() { if(day > 0) day--; else Set(Get() - 1); return *this; }
Date() { year = -32768; day = month = 0; }
Date(const Nuller&) { year = -32768; day = month = 0; }
Date(int y, int m, int d) { day = d; month = m; year = y; }

View file

@ -70,6 +70,14 @@ onst]&]
1 if > b.&]
[s3;%% &]
[s4; &]
[s5;:Date`:`:operator`+`+`(`): [_^Date^ Date][@(0.0.255) `&]_[* operator`+`+]()&]
[s2;%% Moves to the next day.&]
[s3; &]
[s4; &]
[s5;:Date`:`:operator`-`-`(`): [_^Date^ Date][@(0.0.255) `&]_[* operator`-`-]()&]
[s2;%% Moves to the previous day.&]
[s3; &]
[s4; &]
[s5;:Date`:`:Low`(`): [@(0.0.255) static] [_^Date^ Date]_[* Low]()&]
[s2;%% Returns the lowest possible date (year 4000).&]
[s3; &]