Infinity loop with dates comparison

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Aug 11 13:02:46 PDT 2015


On Tue, Aug 11, 2015 at 07:56:00PM +0000, Suliman via Digitalmars-d-learn wrote:
[...]
> Date startDate = Date.fromISOExtString("2014-08-01");
> 
> Date currentDate =  to!(Date)(Clock.currTime()-1.days); //because current
> day is not finished
> 
> 	writeln(startDate);
> 	writeln(currentDate);
> 
> 	Date nextday;
> 
> 	while (nextday < currentDate)
> 	{
> 		nextday = startDate + 1.days;
                          ^^^^^^^^^
Because you're always computing from startDate, which is constant. That
should be 'nextday' instead.


> 		writeln(nextday);
> 	}


T

-- 
Making non-nullable pointers is just plugging one hole in a cheese grater. -- Walter Bright


More information about the Digitalmars-d-learn mailing list