Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Date& operator++
Date& operator++ [message #35074] Mon, 09 January 2012 15:48 Go to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
May it be added?

Date& operator++(Date& a)   	   { a.Set(a.Get() + 1); return a; }
Date& operator--(Date& a)   	   { a.Set(a.Get() - 1); return a; }


Best regards
Iñaki
Re: Date& operator++ [message #35076 is a reply to message #35074] Mon, 09 January 2012 16:55 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Why not, its there (as member function).

What about a little optimization:

Date& operator++() { if(day < 28) day++; else Set(Get() + 1); return *this; }

?

Mirek
Re: Date& operator++ [message #35078 is a reply to message #35076] Mon, 09 January 2012 22:03 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Smile Smile

Best regards
Iñaki
Re: Date& operator++ [message #35082 is a reply to message #35078] Tue, 10 January 2012 15:51 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
So would this be possible ? Smile

Date& operator--() { if(day) day--; else Set(Get() - 1); return *this; }


Best regards
Iñaki
Re: Date& operator++ [message #35083 is a reply to message #35082] Tue, 10 January 2012 16:11 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
koldo wrote on Tue, 10 January 2012 15:51

So would this be possible ? Smile

Date& operator--() { if(day [B]> 1[/B]) day--; else Set(Get() - 1); return *this; }


Re: Date& operator++ [message #35084 is a reply to message #35082] Tue, 10 January 2012 21:12 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Tue, 10 January 2012 09:51

So would this be possible ? Smile

Date& operator--() { if(day) day--; else Set(Get() - 1); return *this; }



Sure, already done, not worth mentioning (as it is the same trick)

Mirek
Re: Date& operator++ [message #35085 is a reply to message #35084] Tue, 10 January 2012 21:14 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Uuups, true Smile.

Best regards
Iñaki
Re: Date& operator++ [message #35092 is a reply to message #35074] Wed, 11 January 2012 10:22 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
"day > 1" would work a tad better (as Zbych tried to point out)? Or it doesn't matter?
Re: Date& operator++ [message #35095 is a reply to message #35092] Wed, 11 January 2012 10:59 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
mr_ped wrote on Wed, 11 January 2012 10:22

"day > 1" would work a tad better (as Zbych tried to point out)? Or it doesn't matter?


As far as I know day numbers start from 1 not from 0 Smile
And this bug is already in SVN:
http://code.google.com/p/upp-mirror/source/diff?spec=svn4382 &r=4382&format=side&path=/trunk/uppsrc/Core/Time Date.h
Re: Date& operator++ [message #35096 is a reply to message #35095] Wed, 11 January 2012 11:23 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
TTTrue!

Best regards
Iñaki
Re: Date& operator++ [message #35099 is a reply to message #35095] Wed, 11 January 2012 11:53 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Zbych wrote on Wed, 11 January 2012 04:59

mr_ped wrote on Wed, 11 January 2012 10:22

"day > 1" would work a tad better (as Zbych tried to point out)? Or it doesn't matter?


As far as I know day numbers start from 1 not from 0 Smile
And this bug is already in SVN:
http://code.google.com/p/upp-mirror/source/diff?spec=svn4382 &r=4382&format=side&path=/trunk/uppsrc/Core/Time Date.h



Ops. Yes. Sry.

Mirek
Previous Topic: Preferred way to access VectorMap
Next Topic: Init a ctrl inside INITBLOCK
Goto Forum:
  


Current Time: Fri Apr 19 14:06:02 CEST 2024

Total time taken to generate the page: 0.08062 seconds