Just a sample of the Echomail archive
[ << oldest | < older | list | newer > | newest >> ]
|  Message 73  |
|  Richard Webb to Paul Quinn  |
|  another convoluted brainteaser for the g  |
|  08 Feb 12 13:57:33  |
 
HI Paul,
On Wed 2012-Feb-08 15:22, Paul Quinn (3:640/384) wrote to Mark Lewis:
PQ> Hi! mark,
RW>> edit it for leap years, since by default it assumes February has
RW>> 28 days.
ml> you know that you can automatically handle this with a small bit of
ml> math, right? i'd have to look at some code to make sure i state it
ml> correctly but leap years can be determined by current year div 4 but
ml> there's also a 400 involved...
PQ> I think the 400 test is for century years, like: 1900, 2000, 2100 &
PQ> so on.
Think you might be right, I'm pre coffee at the moment but
that sounds right.
ml> this is why i need to take a sec later
ml> on and look at the real formula... then you can have an array with
ml> all of the month days count and automatically adjust FEB when it has
ml> 29 days ;)
PQ> How about a bit of something in some old Turbo-C...
PQ> --- 8< ---
PQ> int leap_yr_test(int test_yr)
PQ> /*
PQ> function determines if a given year is a leap year
PQ> Uses: 'test_yr' which is defined prior to function call
PQ> Pre: none
PQ> Post: a boolean value is returned indicating TRUE/FALSE
PQ> */
PQ> {
PQ> /* local variables */
PQ> int result = FALSE;
Ah so if one were to compile that does it give you an
errorlevel if true and another if false?
test_yr easy to define, especially as an environment
variable as in
logecho $C$Y | nset test_yr=$1
USes HOrst's logecho and nset.
PQ> switch (test_yr % 100)
PQ> {
PQ> case 0 : if ((test_yr % 400) == 0) result = TRUE; break;
PQ> default : if ((test_yr % 4) == 0) result = TRUE;
PQ> }
PQ> /* end switch. */
PQ> return(result);
PQ> }
PQ> /* end function. */
PQ> --- 8< ---
PQ> =:)
INteresting!
Regards,
Richard
---
* Origin: (1:116/901)
|
[ << oldest | < older | list | newer > | newest >> ]