Code: Select all
N(1) = N(1) + (Yr % 4 = 0) | (Yr % 100 = 0) | (Yr % 400 = 0)like If, While, Repeat. Use Bool() instead.
?? Worked in the past..

Code: Select all
N(1) = N(1) + (Yr % 4 = 0) | (Yr % 100 = 0) | (Yr % 400 = 0)Code: Select all
N(1) = N(1) + Bool(Yr % 4 = 0) | Bool(Yr % 100 = 0) | Bool(Yr % 400 = 0)

Code: Select all
N(1) + Bool((year % 4 = 0 And year % 100 <> 0) Or year % 400 = 0)

Yes, that's good. And your fine code can be even more improved. The following snippet yields exactly the same results as Stargate's code:utopiomania wrote:Stargåte just put things right by explaining to me how to use
Bool() to make this new >PB> version understand it
Code: Select all
N(1) = N(1) + Bool(Yr % 4 = 0)Code: Select all
N(1) = N(1) + Bool(Yr % 4 = 0) - 4 + 7 - 3I don't think that many people care whether you privately use some flawed code which just works by chance in particular cases.utopiomania wrote:The code calculated leap years correctly until newer versions of PB stopped calculating and throwed a syntax error...

The algorithm and code is and was correct, and is not flawed, the problem had to do with syntax, not flawed logick or algorithms.I don't think that many people care whether you privately use some flawed code which just works by chance in particular cases.
But when you post wrong code in a public forum, it shouldn't be too much of a surprise when someone corrects it.

Obviously, logical thinking and sense of reality are also on your ignore list.utopiomania wrote:The algorithm and code is and was correct, and is not flawed [...]
And, you are on my ignore list, so go awayBye.

Code: Select all
Debug Date(2013, 02, 29, 12, 00, 00)
;Returns -1Code: Select all
Debug Date(2013, 02, 28, 12, 00, 00)
;Returns 1362009600For dates within the limits of PB's date functions.For cimplicity's sake, to test for a leap year you could just use the built in Date() function

rsts wrote:For dates within the limits of PB's date functions.For cimplicity's sake, to test for a leap year you could just use the built in Date() function
It wasn'tBrandon Parker wrote: I thought that was a given.......![]()
{:0)
Brandon
in order to see the different results of both code snippets, try e.g. for year = 1900.

rsts wrote:It wasn'tBrandon Parker wrote: I thought that was a given.......![]()
{:0)
Brandonin order to see the different results of both code snippets, try e.g. for year = 1900.
